I upgraded from GCM to FCM and now I'm testing the experience of upgrading users
I have the following steps
- install the app version that supports GCM
- Upgrade to a new version that supports FCM
- Send push message on Firebase console
The problem is that I see the message received on the notification area in the device, but it doesn't invoke the code CloudMessagingListenerService extends FirebaseMessagingService
I have a debug log at the beginning of CloudMessagingListenerService#onMessageReceived
After I go to the app info and select force stop and reopen the app my code inside CloudMessagingListenerService#onMessageReceived
is called properly.
Any idea what causes this and what can be done to avoid the force kill (my users won't do it voluntarily)
in both scenarios the app is in the background
Update:
The problem is w/ receiving messages from the Firebase console.
I added logs in CloudMessagingListenerService#onCreate
and CloudMessagingListenerService#onDestroy
and I can see that they are called w/ a 100ms time diff between them - while CloudMessagingListenerService#onMessageReceived
isn't called so it seems FirebaseMessagingService
decides to handle the notification but not the data portion
Regarding messages sent from the server:
this is the json I send from the server - the data part is propagated correctly to my code, but the notification is ignored, when I check what is the content of remoteMessage.getNotification()
I get null
{
"to": "my token",
"collapse_key": "my app",
"notification": {
"title": "server title",
"body": "server text"
},
"data": {
"tag": "debug",
"action": "custom-push",
...
}
}