chore: bump firebase and migrate code.
Signed-off-by: xsahil03x <xdsahil@gmail.com>
This commit is contained in:
@@ -210,7 +210,7 @@ class _StreamChatSampleAppState extends State<StreamChatSampleApp>
|
|||||||
// Navigates to Channel page, which is associated with the notification.
|
// Navigates to Channel page, which is associated with the notification.
|
||||||
GoRouter.of(_navigatorKey.currentContext!).pushNamed(
|
GoRouter.of(_navigatorKey.currentContext!).pushNamed(
|
||||||
Routes.CHANNEL_PAGE.name,
|
Routes.CHANNEL_PAGE.name,
|
||||||
params: Routes.CHANNEL_PAGE.params(channel),
|
pathParameters: Routes.CHANNEL_PAGE.params(channel),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,52 +11,48 @@ void showLocalNotification(
|
|||||||
String currentUserId,
|
String currentUserId,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) async {
|
) async {
|
||||||
|
// Don't show notification if the event is from the current user.
|
||||||
|
if (event.user!.id == currentUserId) return;
|
||||||
|
|
||||||
|
// Don't show notification if the event is not a message.
|
||||||
if (![
|
if (![
|
||||||
EventType.messageNew,
|
EventType.messageNew,
|
||||||
EventType.notificationMessageNew,
|
EventType.notificationMessageNew,
|
||||||
].contains(event.type) ||
|
].contains(event.type)) return;
|
||||||
event.user!.id == currentUserId) {
|
|
||||||
return;
|
// Return if the message is null.
|
||||||
}
|
|
||||||
if (event.message == null) return;
|
if (event.message == null) return;
|
||||||
|
|
||||||
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
const initializationSettingsAndroid =
|
|
||||||
AndroidInitializationSettings('ic_notification_in_app');
|
|
||||||
const initializationSettingsIOS = IOSInitializationSettings();
|
|
||||||
const initializationSettings = InitializationSettings(
|
const initializationSettings = InitializationSettings(
|
||||||
android: initializationSettingsAndroid,
|
iOS: DarwinInitializationSettings(),
|
||||||
iOS: initializationSettingsIOS,
|
android: AndroidInitializationSettings('ic_notification_in_app'),
|
||||||
);
|
);
|
||||||
|
|
||||||
final appLocalizations = AppLocalizations.of(context);
|
final appLocalizations = AppLocalizations.of(context);
|
||||||
|
|
||||||
await flutterLocalNotificationsPlugin.initialize(
|
await flutterLocalNotificationsPlugin.initialize(
|
||||||
initializationSettings,
|
initializationSettings,
|
||||||
onSelectNotification: (channelCid) async {
|
onDidReceiveNotificationResponse: (response) async {
|
||||||
if (channelCid != null) {
|
final channelCid = response.payload;
|
||||||
final client = StreamChat.of(context).client;
|
if (channelCid == null) return;
|
||||||
final router = GoRouter.of(context);
|
|
||||||
|
|
||||||
var channel = client.state.channels[channelCid];
|
final channelType = channelCid.split(':')[0];
|
||||||
|
final channelId = channelCid.split(':')[1];
|
||||||
|
|
||||||
if (channel == null) {
|
final client = StreamChat.of(context).client;
|
||||||
final splits = channelCid.split(':');
|
final router = GoRouter.of(context);
|
||||||
final type = splits[0];
|
|
||||||
final id = splits[1];
|
|
||||||
channel = client.channel(
|
|
||||||
type,
|
|
||||||
id: id,
|
|
||||||
);
|
|
||||||
await channel.watch();
|
|
||||||
}
|
|
||||||
|
|
||||||
router.pushNamed(
|
final channel = client.channel(channelType, id: channelId);
|
||||||
Routes.CHANNEL_PAGE.name,
|
await channel.watch();
|
||||||
pathParameters: Routes.CHANNEL_PAGE.params(channel),
|
|
||||||
);
|
router.pushNamed(
|
||||||
}
|
Routes.CHANNEL_PAGE.name,
|
||||||
|
pathParameters: Routes.CHANNEL_PAGE.params(channel),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await flutterLocalNotificationsPlugin.show(
|
await flutterLocalNotificationsPlugin.show(
|
||||||
event.message!.id.hashCode,
|
event.message!.id.hashCode,
|
||||||
event.message!.user!.name,
|
event.message!.user!.name,
|
||||||
@@ -69,7 +65,7 @@ void showLocalNotification(
|
|||||||
priority: Priority.high,
|
priority: Priority.high,
|
||||||
importance: Importance.high,
|
importance: Importance.high,
|
||||||
),
|
),
|
||||||
iOS: const IOSNotificationDetails(),
|
iOS: const DarwinNotificationDetails(),
|
||||||
),
|
),
|
||||||
payload: '${event.channelType}:${event.channelId}',
|
payload: '${event.channelType}:${event.channelId}',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ publish_to: "none"
|
|||||||
version: 2.2.0
|
version: 2.2.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -26,7 +26,7 @@ dependencies:
|
|||||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||||
ref: develop
|
ref: develop
|
||||||
path: packages/stream_chat_localizations
|
path: packages/stream_chat_localizations
|
||||||
flutter_local_notifications: ^9.0.0
|
flutter_local_notifications: ^14.1.1
|
||||||
flutter_svg: ^2.0.7
|
flutter_svg: ^2.0.7
|
||||||
flutter_secure_storage: ^8.0.0
|
flutter_secure_storage: ^8.0.0
|
||||||
yaml: ^3.1.2
|
yaml: ^3.1.2
|
||||||
@@ -39,7 +39,8 @@ dependencies:
|
|||||||
go_router: ^8.0.5
|
go_router: ^8.0.5
|
||||||
provider: ^6.0.5
|
provider: ^6.0.5
|
||||||
video_player: ^2.6.1
|
video_player: ^2.6.1
|
||||||
firebase_messaging: ^14.5.0
|
firebase_core: ^2.14.0
|
||||||
|
firebase_messaging: ^14.6.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: ^0.13.1
|
flutter_launcher_icons: ^0.13.1
|
||||||
|
|||||||
Reference in New Issue
Block a user