Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background GCM Push Notification Not Received on Certain Apple Devices

I have my iOS app set up to receive push notifications via GCM. Having set everything up, I am able to receive notifications when the app is in the foreground on various Apple devices. However, when the app is in the background, I only receive push notifications for certain devices, namely only my iPhone 6. Other devices, such as an iPhone 5s and an iPod Touch are only able to capture notifications when the app is in the foreground.

I looked into other people's questions regarding this issue, bug I have yet to see one that is device model specific. Often it comes down to not setting the content_available: true setting, but I have it set. Here is an example of a payload I am using:

{
    "to":".....",
    "content_available":true,
    "notification": {
            "title":"my title",
            "body":"my body",
            "sound":"default"
    }
}

I receive this background notification exactly how I'd want to on my iPhone 6 (my phone is woken and I see a banner), but other devices (which are also using iOS v8.4.1) do not respond to the notification when the app is in the background.

Other details:

  • I am using Enterprise build
  • I am using the production APN server (and specify so in the GCM registration options)
  • Although I don't think it's necessary, I have all the devices registered with my Apple developer account.

Any thoughts would be appreciated.

like image 529
ericcccc Avatar asked Sep 05 '15 06:09

ericcccc


People also ask

How do I get notifications on all Apple devices?

In the Messages app on your Mac, choose Messages > Preferences, then click iMessage. In the Settings pane, select Enable Messages in iCloud. The messages from your other devices that use the same Apple ID appear on your Mac. Note: Depending on how many messages you have, it may take a while for all of them to appear.

Does Apple block push notifications?

iOS enables you to both disable push notifications entirely, or turn them off for individual apps. To access iOS notifications settings, go into the Settings > Notifications menu. From that list, you can configure each app's notifications settings or disable them.


1 Answers

You should add the priority parameter to your request. For example

{
    "to":".....",
    "content_available":true,
    "priority": "high", // Add this field corresponds to 10 for APNS
    "notification": {
            "title":"my title",
            "body":"my body",
            "sound":"default"
    } 
}

Here is the GCM reference that mentions the priority field. In case you do not set the priority level the message is sent via Normal priority which in APNS's case is highly variable.

like image 67
evanescent Avatar answered Sep 22 '22 01:09

evanescent