changes
This commit is contained in:
+76
-13
@@ -63,25 +63,88 @@ class _MyAppState extends State<MyApp> {
|
||||
_handleMessage(initialMessage);
|
||||
}
|
||||
|
||||
if (kIsWeb) {
|
||||
FirebaseMessaging.onMessage.listen((event) {
|
||||
final overlayCtx = rootNavigatorKey.currentContext;
|
||||
if (overlayCtx != null) {
|
||||
if (overlayCtx.mounted) {
|
||||
AppToast.notification(
|
||||
overlayCtx,
|
||||
event.notification?.title ?? 'New Notification',
|
||||
event.notification?.body ?? 'New Notification',
|
||||
);
|
||||
}
|
||||
// if (kIsWeb) {
|
||||
FirebaseMessaging.onMessage.listen((event) {
|
||||
final overlayCtx = rootNavigatorKey.currentContext;
|
||||
AppLogger().error('Notification received: ${event.notification?.web}');
|
||||
AppLogger().error('web link: ${event.notification?.title}');
|
||||
AppLogger().error('web link: ${event.notification?.web?.link}');
|
||||
print('Notification received1: ${event.notification?.web.toString()}');
|
||||
print(
|
||||
'Notification received1: ${event.notification?.web?.analyticsLabel}',
|
||||
);
|
||||
|
||||
print('web link: ${event.notification?.web?.link}');
|
||||
print('Notification received: ${event.notification?.title}');
|
||||
AppLogger().error('notif data: ${event.data}');
|
||||
AppLogger().error('notif from: ${event.from}');
|
||||
AppLogger().error('notif type: ${event.messageType}');
|
||||
AppLogger().error('notif keys: ${event.data.keys}');
|
||||
AppLogger().info('notif title: ${event.notification?.title}');
|
||||
AppLogger().info('notif body: ${event.notification?.body}');
|
||||
AppLogger().info('notif data: ${event.data}');
|
||||
AppLogger().info('notif from: ${event.from}');
|
||||
AppLogger().info('notif type: ${event.messageType}');
|
||||
AppLogger().info('notif keys: ${event.data.keys}');
|
||||
if (overlayCtx != null) {
|
||||
if (overlayCtx.mounted) {
|
||||
AppLogger().error(
|
||||
'Notification received: ${event.notification?.web}',
|
||||
);
|
||||
AppLogger().error(
|
||||
' link android: ${event.notification?.android?.link}',
|
||||
);
|
||||
AppLogger().error(
|
||||
'android link image: ${event.notification?.android?.imageUrl}',
|
||||
);
|
||||
AppLogger().error(
|
||||
'android link click action: ${event.notification?.android?.clickAction}',
|
||||
);
|
||||
AppLogger().error(
|
||||
'web link image: ${event.notification?.web?.image}',
|
||||
);
|
||||
print('Notification received: ${event.notification?.web}');
|
||||
print('web link: ${event.notification?.web?.link}');
|
||||
AppToast.notification(
|
||||
overlayCtx,
|
||||
event.notification?.title ?? 'New Notification',
|
||||
event.notification?.body ?? 'New Notification',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// }
|
||||
|
||||
FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
|
||||
}
|
||||
|
||||
void _handleMessage(RemoteMessage message) {
|
||||
SharedPreferences.getInstance().then((value) {
|
||||
value.setString('notif_data', message.data.toString());
|
||||
value.setString('notif_from', message.from.toString());
|
||||
value.setString('notif_type', message.messageType.toString());
|
||||
value.setString('notif_keys', message.data.keys.toString());
|
||||
value.setString('notif_title', message.notification?.title ?? '');
|
||||
value.setString('notif_body', message.notification?.body ?? '');
|
||||
value.setString('notif_data', message.contentAvailable.toString());
|
||||
value.setString('notif_web_link', message.notification?.web?.link ?? '');
|
||||
value.setString(
|
||||
'notif_android_link',
|
||||
message.notification?.android?.link ?? '',
|
||||
);
|
||||
value.setString(
|
||||
'notif_web_image',
|
||||
message.notification?.web?.image ?? '',
|
||||
);
|
||||
value.setString(
|
||||
'notif_android_image',
|
||||
message.notification?.android?.imageUrl ?? '',
|
||||
);
|
||||
value.setString(
|
||||
'notif_web_click_action',
|
||||
message.notification?.web?.link ?? '',
|
||||
);
|
||||
});
|
||||
appRouter.go(
|
||||
const SplashScreenRoute(navigateToNotification: true).location,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user