chore: bump firebase and migrate code.

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