'I can't control how the app opens the notification message with firebase

enter image description here

FirebaseMessaging.onMessageOpenedApp is not working

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
  debugPrint("CLICKED!");
  RemoteNotification? notification = message.notification;
  AndroidNotification? android = message.notification?.android;

  debugPrint("id: ${notification?.body}");

  if (android != null && notification != null) {
    Navigator.push(
      context,
      MaterialPageRoute(builder: (context) => const NotificationScreen()),
    );
  }
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source