I'm implementing code for notification navigation after user press on notification. Below is my code.
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage? message) {
if (message != null) {
handleNavigationToScreen(message);
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
handleNavigationToScreen(message);
});
Code is working when application is killed or in background. The problem that i have is when application is in foreground and receive notification.
In this case i handle notification with:
FirebaseMessaging.onMessage.listen(showFlutterNotification);
void showFlutterNotification(RemoteMessage message) async {
flutterLocalNotificationsPlugin.show(
notification.hashCode,
notification.title,
notification.body,
NotificationDetails(
android: AndroidNotificationDetails(
channel.id,
channel.name,
channelDescription: channel.description,
styleInformation: bigPictureStyleInformation,
icon: '@mipmap/ic_launcher',
),
),
);
}
The problem is when i press on notification that was shown with "flutterLocalNotificationsPlugin.show", is not trigged FirebaseMessaging.onMessageOpenedApp.listen.
Is there any other way to get callback on notification press to handle screen navigation.
Thanks