cordova-plugin-firebase-messaging icon indicating copy to clipboard operation
cordova-plugin-firebase-messaging copied to clipboard

Read gcm data when notification arrived in background/coldstart on Android

Open chemerisuk opened this issue 8 years ago • 6 comments

chemerisuk avatar Oct 10 '16 14:10 chemerisuk

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

rgfpy avatar Jul 25 '17 14:07 rgfpy

Any news on this issue?

h4rm avatar Dec 03 '18 20:12 h4rm

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.

AitorAppCoder avatar Dec 13 '18 18:12 AitorAppCoder

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 } }

jamesfdickinson avatar Jul 11 '19 18:07 jamesfdickinson

I have a similar issue, further explained here

luisVargasGu avatar Apr 21 '21 14:04 luisVargasGu

 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.

aravindforums1 avatar Nov 13 '22 07:11 aravindforums1