Closed jmeyers91 closed 5 years ago
I have the same problem. That is my payload sent to https://fcm.googleapis.com/fcm/send:
{
"to" : "registrationId",
"notification" : {
"body": "Hello"
},
"data" : {
"custom_data" : "test"
}
}
I'm using the same cordova, android and plugin version that @jmeyers91
Please (re)read this section of the docs and see if it explains well enough why you shouldn't send both notification
and data
root attributes on the payload: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads
If it doesn't, please help us improve the docs.
Also, if this is not the root of the problem (and using data
-only payload doesn't solve it), feel free to re-open the issue.
This thread has been automatically locked.
Expected Behaviour
When I press a notification, my app should be launched and then either receive the
notification
event or there should be some mechanism to check the launch notification.Actual Behaviour
No
notification
event is received and there doesn't appear to be any way to access the notification used to launch the app.Reproduce Scenario (including but not limited to)
I run
PushNotification.init
then I ensure I have permissions withPushNotification.hasPermission
then I listen for the registration token withpushNotifications.on('registration')
then I send it to the server and listen for anotification
event. The event is received if the app is in the foreground, but it isn't received if the app is launched from the notification from being terminated or in the background.I've also tried adding the
notification
listener immediately after thedeviceready
event in-case I was missing it.Steps to Reproduce
Send a notification to an Android phone while the listening app is in the background/terminated. Press the notification. Observe that no notification event was received by the app.
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android 8.0.0
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
LG G6
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload
The full code used to send test notifications (from Node using the
firebase-admin
module)