In my flutter project I have configured to received Firebase messages when the app is opened or closed.
But when the notification is triggered with the app closed, upon clicking in the notification and opening the app, the notification is triggered again. Is that a known issue or am I configuring something wrong?
@override
void initState() {
super.initState();
_initFuture = initData();
messaging = FirebaseMessaging.instance;
_requestNotificationPermissions();
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
NotificationService().showNotification(message);
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
NotificationService().showNotification(message);
});
}
I tried using an approach suggested somewhere else about checking the messageId so it validates before continuinng , but that didn’t work out.
2
Answers
You just have to add condition for the platform and remove the onMessageOpenedApp from there,
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
NotificationService().showNotification(message); });
Don’t call this NotificationService().showNotification(message)
for now then check . you will get only time.