MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.47k stars 1.4k forks source link

while clicking on notificaton in background state ,calling terminated state #2320

Closed premchanduv closed 5 months ago

premchanduv commented 6 months ago

Describe the bug while clicking on notification when app is background state app is opening via messageonopenedappstream but immediately it is calling getinitalmessagemethod

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior while clicking on notification via background state it should open desired page only once dont call getinitalmessage

Sample code to reproduce the problem FirebaseMessaging.instance.getInitialMessage().then((event1) { if (event1?.notification != null) { if(event1?.notification!.title=='New Order'){

  Future.delayed(const Duration(seconds: 1), () async {

    Get.toNamed(Kneworderscreen, arguments: event1?.data);
});

}
else{
  //Get.toNamed(Ksplash);

handleMessage(event1!, context); } print("Launched from terminated state");

} });

FirebaseMessaging.onMessageOpenedApp.listen((event) { print('identi'); // NotificationServices notificationServices=NotificationServices(); // notificationServices.firebaseInit(); // notificationServices.showNotification(event); if(event.notification!=null){ if (event.notification!.title.toString()=='New Order'){

  Get.offNamed(Kneworderscreen, arguments: event.data);
}
else{
handleMessage(event, context);
}
MaikuB commented 5 months ago

What you're referring to is to do with the FCM plugin not this plugin