Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase onMessageReceived not called when app is Killed

There's been trending topics about Firebase Cloud Messaging that Data Payload message is not fired from onMessageReceived() method for some lower-end devices. And it's true. Here is the result:

App getting killed scenario:

Devices got data payload:

  1. Nexus 5X : OS 7.1

Devices didn't get data payload:

  1. Xiaomi MI 4C : OS 5.1
  2. Huawei LUA-U22 : OS 5.1

Be ensured that I'm not sending notification key from Server/Postman.

I am looking for the solution, I got data payload from Firebase including all types of devices, OS & obviously from API level 15. My Postman details are as follows.

 {
    "registration_ids": ["fC5uxGSRCsg:APA91bHh9fMXQ41LpX6tjjSsBKGrKTWYpzKimLDzvBGSHDPo2pq87JHqogUp2kqrmJi06siG_p6DfgRCim23iFzlBQAIrgtMDqRW4s39zUqv9CzyPqzxVl5PtnHPRDs4OagTuTePNyDI"],
    "data": {
        "title" : "my_custom_value",
        "message" : "tekksdasdasdsa",
         "isBackground" : "",
          "payload" : {


          },
           "timestamp" : "",
            "imageUrl" : "",
     }

}
like image 527
Md Shihab Uddin Avatar asked Sep 14 '17 06:09

Md Shihab Uddin


1 Answers

In some devices Like MI you will not receive Notification if the application is removed from application tray! but you will receive notifications if you killed an activity and haven't removed from application tray!

In Xiaomi phones, they whitelist or blacklist an app based on certain criteria. If you download an app and if it is in their whitelist, they'll permit the app to show notifications.
How to Test:-
Try testing your app after killing your app activities rather removing from app tray if that works fine , thats all you could do at your end!

like image 200
phpdroid Avatar answered Oct 26 '22 11:10

phpdroid