ios - 当iOS应用程序被杀死时,Gcm不会发送到应用程序

标签 ios iphone google-cloud-messaging

Gcm 在前台和后台时发送到 apn。 <- 发送好

但是如果强制退出应用程序,gcm 不会发送到 apn。 <- 发送不正确

当强制退出应用程序时,apn 可以发送通知,因为“APN 测试器”发送通知可用。

<测试条件>

iPhone 4

7.1.2

对象 c 代码(GcmExample.app)

使用 curl

< curl --header "Authorization: key=$server_api_key" \
--header Content-Type:"application/json" \
https://android.googleapis.com/gcm/send \
-d "{\"data\":{\"title\":\"title\"},\"notification\":{\"body\":\"noti test\",\"content_available\":true},\"to\":\"$token\"}" >

<等使用>
"GcmServerDemo"工具
"APN Tester"工具

最佳答案

您应该尝试一 strip 有 high APNS priority 的消息例如

 curl --header "Authorization: key=$server_api_key" \
      --header Content-Type:"application/json" \
      https://android.googleapis.com/gcm/send \
      -d "{
         'data': { 'title': 'title' }, \
         'notification': {'body': 'notitest' }, \
         'content_available': true, \
         'to': '$token', \
         'priority': 10,
      }"

您需要设置 priority明确到 10否则 GCM 假定正常的 APNS 优先级可能会被高度延迟。

Here is the GCM reference您可以在哪里阅读 priority field 。

关于ios - 当iOS应用程序被杀死时,Gcm不会发送到应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32370942/

相关文章:

ios - 在 ios8 中使用 swift 语言发送短信

iphone - NSComparisonResult 和 NSComparator - 它们是什么?

ios - UICollectionView 的大小有时是错误的

android - GCM 在弃用后是否会为使用 GCM 的老客户提供新 token

ios - GCM 始终为 iOS 设备返回 "NotRegistered"

ios - 使用 super.init 使用 xib 创建自定义 View 的目的是什么?

ios - 如何在渲染后重用 map View

ios - 在谷歌地图 iOS 中解析 Json

ios - 检测空 UITextField 中的退格键

android - 模拟器只收到 GCM 消息?