Read gcm data when notification arrived in background/coldstart on Android
chemerisuk opened this issue · 6 comments
view this project https://github.com/infobip/mobile-messaging-cordova-plugin/ in this is available functions to read in background arrived, for get some ideas
Any news on this issue?
First of all, thank you for all the work done, it's a great plugin.
Well, I just found out too this feature isn't included... and It's a really important one: Having the possibility to do certain expected actions even if the user didn't click the notification.
This should really be implemented. The possibilities left to escape this void are not many, nor good.
I thought this was a show stopper, but after further research it was not. This seems to be by design by android. When the app is in the background and the notification is tapped on, the action intent is triggered instead of the onMessageReceived event. The data portion of the payload is preserved but not the notification part. For my purposes all I needed was the data portion in my app. Also if you exclude the notification section, it will not show a notification but will trigger the onMessageReceived while your app is in the background or foreground.
{
"notification": {
"title": "Cribbage JD",
"body": "You have challenged to a game"
},
"data": {
"my_custom_key": "my_custom_value",
"my_custom_key2": true
}
}
I have a similar issue, further explained here
cordova.plugins.firebase.messaging.onBackgroundMessage(function (payload) {
alert(payload.my_custom_key);
alert(payload.my_custom_key2);
});
Use this function to receive payload and get data in mobile device, write this function in ondeviceready function in index.js file.