Closed presidenten closed 7 years ago
@presidenten try without the quotes around 1. IIRC iOS needs it to be an int.
var data = {
title: 'A notification',
'content-available': 1
};
Thanks, I just tried, and still no response. Thought I might also say that I have "Remote notifications" on in "Background modes" in the project. I also double checked that I have given all permissions on my iphone.
If you send content-available = 1 that means it's a silent notification:
For a silent notification, take care to ensure there is no alert, sound, or badge payload in the aps dictionary. If you don’t follow this guidance, the incorrectly-configured notification might be throttled and not delivered to the app in the background, and instead of being silent is displayed to the user.
@jcesarmobile Just tried sending this (print out from node-pushnotifications on npm (uses node-apn))
{ encoding: 'utf8', payload: { 'content-available': 1 }, expiry: 1469895173, priority: 10, retryLimit: -1, device: undefined, compiled: false, truncateAtWordEnd: false, content_available: true }
Still nothing. This time ofcourse not even a notification.
I receive it when the app is in the foreground though, then it looks like this (from javascript) 2016-07-30 17:56:54.103 PokeNotifier for Pokemon GO[3327:2108881] got notification!! 2016-07-30 17:56:54.103 PokeNotifier for Pokemon GO[3327:2108881] { "additionalData": { "content-available": 1, "foreground": true, "coldstart": false } }
Woho! I got it to work!!!
Very strange though. I had to set contentAvailable: 1
camelcased, not snakecased, together with the defaultData in the node plugin settings.
Then I got the following in app:
{
"content-available": 1,
"additionalData": {
"foreground": false,
"coldstart": false
}
}
Where the content-available
is outside the additionalData
.
Interestingly enough I also get it to work together with a notification text now. Once again, thanks guys! It felt that I tried everything, but then I finally tried to print out the contentAvailable variable in AppDelegate+notification.m and saw it was 0 all the time no matter and then just took a swing at trying camelcased :-)
Maybe its the node push plugin that does something strange? I dont know. I dont care. Now it works. Im happy :-)
Im closing this and leaving it for future reference.
This thread has been automatically locked.
Expected Behaviour
When the application is running in the background and receives a notification with 'content-available' = 1, the didReceiveRemoteNotification should run and trigger my on('onNotification') function in javascript.
Actual Behaviour
I receive a notification that is displayed, but nothing happens on the iphone. If I press the notification the app is started and the notification is processed. If I switch to the app, the notification is lost in cyberspace.
Reproduce Scenario (including but not limited to)
Steps to Reproduce
cordova platform add ios cordova add plugin through "cordova plugin add phonegap-plugin-push --variable SENDER_ID="my id" cordova build ios