Reputation: 936
I have to catch up notification from GCM. I don't receive any notification when my app is in background mode. But I can see them when it is in foreground.
for test functionality of GCM i use it:
curl -X POST -H "Authorization: key= KKKKKKKKKKKK" -H "Content-Type: application/json" -d '{"to":"XXXXXXXXX","data":{"message": "It is special push notification for test!!!"}}' https://gcm-http.googleapis.com/gcm/send
I see this message (if app is active). but when I use it:
curl -X POST -H "Authorization: key= KKKKKKKKKKK" -H "Content-Type: application/json" -d '{"to":"XXXXXXXX","data":{"message": "It is special push notification for test!!!"},"notification":{"body":"great match!","title":"Portugal vs. Denmark","icon":"myicon"}}' https://gcm-http.googleapis.com/gcm/send
in this case I don't see message.
Do you know how to send notification via GCM which will show when the app is turned off?
P.S. It looks like GCM does not work with APNs.
Upvotes: 4
Views: 1880
Reputation: 4250
You need to send priority parameter as high to notify ios devices.
The description for proirity is;
Sets the priority of the message. Valid values are "normal" and "high." On iOS, these correspond to APNs priority 5 and 10.
By default, messages are sent with normal priority. Normal priority optimizes the client app's battery consumption, and should be used unless immediate delivery is required. For messages with normal priority, the app may receive the message with unspecified delay.
When a message is sent with high priority, it is sent immediately, and the app can wake a sleeping device and open a network connection to your server.
But I think it is not an enough description.
I created a library for Java and its test cases notify apple devices when they are foreground, background or not running.
Upvotes: 1