I am using fcm for push notification , and i am trying to stack the notifications when the internet is off ,
What is happening now is
- When the app doesn't have internet and the app if receives more than one notification , when the interent is switched on , only the latest notification is shown.
What I want to achieve is
- When the app doesn't have internet and the app if receives more than one notification , when the interent is switched on , I want to show all the notifications not just the latest one.
I am presently using the following code snippets.
// Background and also terminated
FirebaseMessaging.instance.getInitialMessage().then((value) =>
Navigator.push(
context, MaterialPageRoute(builder: (context) => DummyScreen())));
// Background not terminated
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print(
"The message from within the onMessageOpenedApp and i am within the home_page is : " +
message.notification!.title.toString());
Navigator.push(
context, MaterialPageRoute(builder: (context) => DummyScreen()));
});
// When app is in foreground
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
if (notification != null && android != null && !kIsWeb) {
flutterLocalNotificationsPlugin.show(
notification.hashCode,
notification.title,
notification.body,
NotificationDetails(
android: AndroidNotificationDetails(
channel.id,
channel.name,
// TODO add a proper drawable resource to android, for now using
// one that already exists in example app.
icon: 'launch_background',
),
),
);
}
});