在某些 Apple 设备上未收到后台 GCM 推送通知 [英] Background GCM Push Notification Not Received on Certain Apple Devices

查看:23
本文介绍了在某些 Apple 设备上未收到后台 GCM 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 iOS 应用设置为通过 GCM 接收推送通知.设置完所有内容后,当应用程序在各种 Apple 设备上处于前台时,我就能收到通知.但是,当应用程序在后台时,我只能收到某些设备的推送通知,即只有我的 iPhone 6.其他设备,例如 iPhone 5s 和 iPod Touch 只能捕获通知当应用在前台时.

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.

我调查了其他人关于这个问题的问题,我还没有看到一个特定于设备型号的问题.通常归结为不设置 content_available: true 设置,但我设置了它.这是我正在使用的有效负载示例:

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"
    }
}

我在 iPhone 6 上完全按照我想要的方式收到此后台通知(我的手机被唤醒,我看到一条横幅),但其他设备(也使用 iOS v8.4.1)不响应通知当应用在后台时.

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.

其他细节:

  • 我使用的是企业版
  • 我正在使用生产 APN 服务器(并在 GCM 注册选项中指定)
  • 虽然我认为没有必要,但我已经使用我的 Apple 开发者帐户注册了所有设备.

如有任何想法,我们将不胜感激.

Any thoughts would be appreciated.

推荐答案

您应该将 priority 参数添加到您的请求中.例如

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"
    } 
}

这是提到 priority 字段的 GCM 参考.如果您没有设置优先级,消息将通过 Normal 优先级发送,在 APNS 的情况下,该优先级是高度可变的.

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.

这篇关于在某些 Apple 设备上未收到后台 GCM 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆