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

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

问题描述

我的iOS应用已设置为通过GCM接收推送通知。设置了所有东西后,我可以在应用程序处于各种Apple设备的前台时收到通知。但是,当应用程序处于后台时,我只接收针对某些设备的推送通知,即仅接收我的iPhone 6.其他设备(例如iPhone 5s和iPod Touch)仅能够捕获通知当应用程序在前台。



我研究了其他人关于这个问题的问题,我还没有看到一个设备模型特定的问题。通常,它不会设置 content_available:true 设置,但我已设置。以下是我使用的有效负载的示例:

  {
to:..... ,
content_available:true,
通知:{
title:my title,
body:my body,
sound:default
}
}

我收到我的iPhone 6上的背景通知究竟如何(我的手机被唤醒并看到横幅),但其他设备(也在使用iOS v8.4.1)在应用程序处于背景。



其他详细信息:


  • 我正在使用Enterprise build
  • >
  • 我正在使用生产APN服务器(并在GCM注册选项中进行了指定)

  • 尽管我不认为这是必要的,但我拥有所有设备在我的Apple开发者帐户中注册。



任何想法都不胜感激。

解决方案

你这么说ld将 priority 参数添加到您的请求中。例如

  {
to:.....,
content_available :true,
priority:high,//为APNS
通知添加此字段对应于10:{
title:my title,
body:my body,
sound:default
}
}

以下是 GCM参考,其中提到了 priority 字段。如果您没有设置优先级,则消息通过正常优先级发送,在APNS情况下,该优先级高度可变。

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.

解决方案

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.

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

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