3

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

Michael A.
  • 2,288
  • 1
  • 18
  • 21
  • 2
    Possible duplicate of [GCM support for ios application when application in background or killed](http://stackoverflow.com/questions/30883607/gcm-support-for-ios-application-when-application-in-background-or-killed). – Mogsdad Apr 19 '16 at 15:42

3 Answers3

1

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.

Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
0

If an iOS Application is killed from the switcher by the user, it will not receive push notifications. This is an OS thing that Apple deliberately implemented so there isn't a work around.

More info can be found here (login required): https://devforums.apple.com/message/873265#873265

Richmond Watkins
  • 1,342
  • 9
  • 17
  • I tried also this use case. Even if the application was killed manually, the notification is shown using APNS directly. It looks not anymore the case with IOS 8. I think It is more related to GCM <-> APNS (as notification is received when bypassing GCM). – Michael A. Aug 25 '15 at 21:30
0

we encountered this issue while trying to send messages to GCM topic, all android devices get the message correctly but not the ios ones where app is killed. Solved issue with sending message both in data and notification objects. Don't forget to put priority to high!!

Sample Json:

{"to":"/topics/xxx",
 "collapse_key":"",
 "data":{"message":"topic notification"},
 "notification":{"body":"topicotification"},
 "time_to_live":3600,
 "content_available":true,
 "priority":"high"}
Serdar
  • 71
  • 1
  • 3