Calvin
Calvin

Reputation: 331

Flutter Firebase Push Notification unable to data if app is not launched

I am using Flutter for my code. For push notification, I am using Firebase Push Notification ("firebase_messaging" version 9.1.3).

I am facing the following issue:

Below is my code that listen to the message (referencing from Flutter example).

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
  //Process received message 
  _processMessage(message);
});

What am I missing to enable the app to receive the notification payload if it launched fresh.

Upvotes: 0

Views: 1531

Answers (1)

Kirill Bubochkin
Kirill Bubochkin

Reputation: 6353

As far as I remember, onMessageOpenedApp is only triggered when the app is launched from the background state.

For receiving notification payload when launching from the terminated state, you have to use getInitialMessage() method.

More on that can be found here.

Upvotes: 1

Related Questions