Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM not sending notification when App ios shutdown

I'm using GCM to send notifications to both android and IOS devices.

On IOS, the notifications are received while application is active or running in background.

However, when the application is down, no notification is received. I tested by contacting directly APNS and the message is received. So the configuration on the device seems Ok.

Here is an example of a message sent to GCM:

{"notification":{
    "badge":"4",
    "body":"Test body",
    "sound":"default",
    "title":"Test title"
},
"collapse_key": "collapse_1",
"message_id": "1000003",
"content_available":true,
"to": "GCM TOKEN FOR DEVICE"
}

This message is received correctly when the application is in background but not when the app is shutdown.

I've sent the supposed message that should be sent to APNS, directly to APNS:

{"aps":{"alert":{"title":"Title","body":"Body"},"badge":5,
"sound":"default", "content-available":1}}

And the device receives this notification.

What am I missing? Is there a specific configuration to authorized GCM to send to APNS?

Thanks a lot, because I'm stuck.

Michael

like image 503
Michael A. Avatar asked Nov 20 '25 15:11

Michael A.


1 Answers

Foreground pushes (i.e. those intended for the user) are always displayed. Background pushes (i.e. those intended for the app) are not sent to the app if the app has been killed. Your push payload doesn't know what it is - its a mixture, it has a body/title/sound which a foreground push would have, but it also has content-available which is for background pushes.

Decide if your push should be a foreground or a background push and then chop out the unnecessary parts from your payload accordingly.

Also starting with iOS 8.1 (or 8.2 I forget which), background pushes will only instantly be delivered to the app if the app is in the foreground or if its in the background and the device is being charged (note, this included being connected to a mac via usb). If the app is in the background and its not being charged then it might take several hours for the push to get delivered to the app.

like image 91
Gruntcakes Avatar answered Nov 23 '25 04:11

Gruntcakes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!