Skip to content

🐛 [firebase_messaging] FirebaseMessaging.onMessageOpenedApp.listen not working #6332

@AgungLaksana

Description

@AgungLaksana

I am using firebase_messaging: ^10.0.1 and firebase_core: ^1.2.0 and also Flutter (Channel stable, 2.2.1)

I want if my user click the notification then I will open a specific page. so I have code like this in my HomePage


class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();

    FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
      print('FCM Notification clicked!');
      // do something after user click the notification
    });
    
  }
}

Expected behavior

I expect that print('FCM Notification clicked!'); will show after I click the push notification from the notification tray, but it seems this FirebaseMessaging.onMessageOpenedApp.listen never triggered after clicking the push notification.

I test it using real device (Redmi Note 7 and Samsung SM J200G) in debug mode but that stream never triggered

Flutter doctor

[✓] Flutter (Channel stable, 2.2.1, on macOS 11.2.1 20D74 darwin-x64, locale en-ID)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.56.2)
[✓] Connected device (4 available)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.resolution: userThis was a user issue, e.g. invalid configuration or code.type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions