Solution:
The problem seems to be with messages sent by Firebase Test Console but I don't know why, yet. I started to send messages by using node-gcm and everything is working as expected from the beginning.
Both messages sent to a single device by device token. Messages in logcat:
- Sent from Firebase Test Console (Not working from bg):
01-06 14:36:06.618 19422 19422 I chromium: [INFO:CONSOLE(95702)] "{"sound":"default","title":"├üFA fizet├ęs 2016.11.30-a","message":"K├Âvetkez┼Ĺ esed├ękes k├Âtelezetts├ęg: ├üFA fizet├ęs 2016.11.30-a","additionalData":{"id":"1","google.message_id":"0:1483709767111210%********","coldstart":false,"collapse_key":"********","foreground":true}}", source: file:///android_asset/www/build/main.js (95702)
- Sent by node-gcm script (Working even from bg):
01-06 14:37:41.037 19422 19422 I chromium: [INFO:CONSOLE(95702)] "{"title":"├üFA fizet├ęs 2016.11.30-a","message":"K├Âvetkez┼Ĺ esed├ękes k├Âtelezetts├ęg: ├üFA fizet├ęs 2016.11.30-a","additionalData":{"id":"1","google.message_id":"0:1483709856368443%*********","coldstart":false,"collapse_key":"do_not_collapse","foreground":false}}", source: file:///android_asset/www/build/main.js (95702)
The difference I see is the collapse_key property, which contains the apk name of the application and the sound. Could this be caused by collapse_key?
Updated shortened version:
- Device registration is successful.
- Test notifications sent from Firebase Test Console.
- They arrive to the device:
- When app is in the foreground, notification event is fired as it should be. OK
- When app is in the background, the message appears on the notification bar of the os. If I click on it, my app gets activated and that's all. The notification event has not been called this way. NOT OK
Original question:
I'm using phonegap-push-plugin and I can not get the notification event fired when the app is in the background and clicking on the notify event on Android.
If the app is active, I can see that the event called on logcat. However if it is in the background and I click on the event notification, the app gets activated and nothing else happens according to logcat events. I have tried adding content-available: 1 as an additional parameter in the Firebase test console, but that didn't help either.
Here is a row from logcat that shows up when the app is active:
01-05 22:41:59.981 9076 9186 V PushPlugin: extrasToJSON:
{"sound":"default","title":"Msg title","message":"Msg
body","additionalData":
{"id":"1","google.message_id":"0:1483652521531127%d86d9************",
"coldstart":false,"collapse_key":"************","foreground":true}}
The code is the same as everywhere else, I have immediate console.logs after the callback has been fired:
push.on('notification', (data) => {
console.log('onNotification'); // not shown when app is in bg
Push plugin send notification when it is in background. There is an event defined in Plugin documentation which fired by notification received , Try to catch the event and send notification using Local Notification plugin.