Open
Description
Future<void> onSelectBackgroundNotification() async {
RemoteMessage? message =
await FirebaseMessaging.instance.getInitialMessage();
if (message?.notification != null) {
_handleMessage(message!.data);
message = null;
log('background Message has been opened');
}
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
RemoteNotification? notification = message.notification;
if (notification != null) {
_handleMessage(message.dat,);
}
});
}
- the code runs when app is in background state and handle message navigates to a page.
this code snippet is worked --
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
RemoteNotification? notification = message.notification;
if (notification != null) {
_handleMessage(message.dat,);
}
});
- when we hot restart from there --
RemoteMessage? message =
await FirebaseMessaging.instance.getInitialMessage();
this return old data of consumed message (fromstep 1) .
and is expected to work atlest 2 to 3 times , then discarded.
Please fix this , or give any suggestion