简体   繁体   中英

Android device not receiving notification message when the app is terminated using Flutter and FCM

I am developing an app using Flutter, and I am implementing push notification using FCM with the firebase_messaging Flutter plug in:

https://pub.dartlang.org/packages/firebase_messaging

on the Readme.md of this plugin, it says when an Android device receives data message while the app has been terminated, the message will be lost, but when the device receives a notification message, the message will show up at the app tray whether the app has been terminated or just in the background.

I have implemented this plugin and it is not behaving the way Readme.md describes. Notification message gets lost on my android device when the app has been terminated.

Here is a sample payload I am sending to the device:

var payload = {
  notification: {
    title: `message from somebody`,
    body: `message text here`,
    }
}

What am I possibly doing wrong? Am I missing something in the payload, or is it something else?

Have you tried using the Firebase Console to send a message. It might be worth while to send a test message using Firebase Console. This way you will be able to eliminate the possibility of having a mistake in your payload.

Another thing to verify would be implementing onMessage onResume and onLaunch in the app and also including a custom data key value pair of click_action: FLUTTER_NOTIFICATION_CLICK in your message.

Last thing would be to check google-services.json was placed in the right folder android/app and also checking both android/build.gradle , android/app/build.gradle were correctly modified.

I hope I was able to provide little help. Let me know if this works.

the firebase_messaging package is not supporting the Data Message receivation when the app is terminated in android and only when app is open or in background.
its saying this about Data Message Receivation When the app is Terminated in android : not supported by plugin, message is lost.
and about the notification , Notification is delivered to system tray. When the user clicks on it to open app onLaunch fires if click_action: FLUTTER_NOTIFICATION_CLICK is set.

take a look at that table in the receiving Messages : https://pub.dartlang.org/packages/firebase_messaging#-readme-tab-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM