Closed miqmago closed 6 years ago
@miqmago I need to see the push message you send to the device not the one that is received by the device.
@macdonst Hi Simon, I'm using our node-pushnotifications which uses node-gcm. If there is something that should be modified and you can help, we can adapt node-pushnotifications to fit the needs. Maybe if you can show me how json
should be in the request, I would try to achieve it and then adapt the library where needed.
This is the final request:
{
"method": "POST",
"headers": {
"Authorization": "key=..."
},
"uri": "https://fcm.googleapis.com/fcm/send",
"json": {
"priority": "high",
"content_available": false,
"delay_while_idle": false,
"time_to_live": 2419200,
"dry_run": false,
"data": {
"content-available": "1",
"force-start": "1",
"title": "hello",
"message": "world",
"icon": "pn_icon.png"
},
"notification": {
"title": "hello",
"body": "world",
"icon": "pn_icon.png"
},
"registration_ids": [
"..."
]
},
"timeout": 180000
}
Other things tried:
"data": {
"content-available": "1",
"force-start": "1",
"title": "hello",
"message": "wow",
"icon": "pn_icon.png"
},
"notification": {
"title": "hello",
"body": "wow",
"icon": "pn_icon.png",
"content-available": "1"
},
also tried with integers and booleans. Also tried directly with content_available
.
@miqmago whelp, this has been discussed many times on the issues here and documented in this section data vs notification payloads.
Move everything out of notification
and it will start to work.
{
"method": "POST",
"headers": {
"Authorization": "key=..."
},
"uri": "https://fcm.googleapis.com/fcm/send",
"json": {
"priority": "high",
"content_available": false,
"delay_while_idle": false,
"time_to_live": 2419200,
"dry_run": false,
"data": {
"content-available": "1",
"force-start": "1",
"title": "hello",
"message": "world",
"icon": "pn_icon.png"
},
"registration_ids": [
"..."
]
},
"timeout": 180000
}
Ouch... Thanks! I'll adapt our plugin. Maybe I would suggest to improve the title of docs, I was looking everywhere but there (I've read all API and also https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#user-clicks-on-notification-in-notification-center, wasted many hours testing and testing and looking on internet about this... maybe a small reference there would help, I'm open to contribute)
@miqmago yup, PR's are always welcome
Same request with the following body: POST https://fcm.googleapis.com/fcm/send
{
"priority": "high",
"content_available": false,
"delay_while_idle": false,
"time_to_live": 2419200,
"dry_run": false,
"data": {
"content-available": "1",
"force-start": "1",
"title": "hello",
"message": "world"
},
"to": "<fcmToken>"
}
RESULT
Notification comes when app has been killed (background case), but when tapped it doesn't execute handler, simply start the app and nothing else. @macdonst @miqmago
This thread has been automatically locked.
Related issue: https://github.com/phonegap/phonegap-plugin-push/issues/1062
Expected Behaviour
Android only, app closed or in background:
content-available
, notification event handlers should be calledActual Behaviour
Android only, app closed or in background:
"content-available": 1
and/or"force-start": 1
or notReproduce Scenario (including but not limited to)
Steps to Reproduce
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
android 8.0, android 7.0
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload
Tried with different combinations, including or not including 'content-available' and/or 'force-start'. Tried also with string, integer or boolean.
Sample Code that illustrates the problem
Ionic PushService:
app.component.ts:
Logs taken while reproducing problem