Murat Ceven
Murat Ceven

Reputation: 264

How do I trigger onMessageReceived() for killed apps?

I implemented Firebase cloud messaging in my Android app and also setup the Firebase console. Those are working perfectly so far for

  1. App in foreground
  2. App in background

But not when my app was killed. According to this answer for point 1.2:

Data Messages: Theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed

What am I missing to receive data for killed apps?

Here the json I pass:

{
    "to": "/topics/testTopic",
    "data": {
        "key1" : "val1",
        "key2" : true
     }
}

I applied the example in the link above in point 2.

Upvotes: 0

Views: 675

Answers (1)

Vishvendu Palawat
Vishvendu Palawat

Reputation: 576

enter image description here

Authorization key will be your server key in the attached Image

{

“data”: { “score”: “45×1”,

“time”: “15:10”

},

“to” : “your server key” }`

About above JSON Format you need to pass from the app server:

“data” will contain your key value pair coming from the server. “to” will be your fcm token, Authorization you will get from the FCM Console -> Setting – >Project setting -> Cloud Messaging and there copy your server key.

Upvotes: 1

Related Questions