Ad

How To Get Push Notification Custom Data From Firebase When App Is Terminated

- 1 answer

Currently, my app gets all the push notifications when in the background and terminated state (currently implementing local notification). When I send custom data in the Firebase console, all the data is correctly passed to the app when it is run foreground and background. However, when the app is terminated, the push message comes but the data is not retrieved successfully(only null data).

Is there any way to solve this? I don't understand why the push comes but then data does not. It would be really nice if you help out!

Ad

Answer

If you app startup from FCM message click when your app terminated, you need to custom this

FirebaseMessaging.instance.getInitialMessage().then((message) { //do something })
Ad
source: stackoverflow.com
Ad