iOS 的 GCM 在未调试时未显示
GCM for iOS not showing while not debugging
我是初学者 iOS 开发人员(所以..如果我犯了一个愚蠢的错误,我深表歉意)。
我已成功实施 GCM,插入时 运行 正常(运行 和 XCode)。但是当我从我的电脑上拔下我的设备时,它不再提示横幅。
所以,当 :
- 已插入 -> 打开应用程序时 -> JSON 收到
- 已插入 -> 当应用程序在后台时 -> 出现横幅
- 未插电 -> 打开应用程序时 -> JSON 收到
- 不插电 -> 当应用程序在后台时 -> 没有
我用这些JSON
{
"content_available":true,
"to" : "l6rofh8dvAc:AP......BVhhXSYc3thtGklEzJzoZFGRMI7lBk4RhmcW",
"message_id": "1",
"notification" :
{
"body" : "helloo!!",
"title" : "GCM",
"icon" : "",
"sound": "default",
"alert":"default",
"badge":"12",
"color": "#03A9F4",
},
"data":
{
"body":"Hello, How are you?",
"title":"Test"
}
}
我的JSON错了吗?还是我在 XCode 错过了什么? (我按照 中的示例
在 iOS 上设置 GCM 客户端应用程序 - 示例(稍作修改)。
您应该将消息的优先级设置为high
。您设置优先级的方式设置为低,APNS 在发送消息时优化电池,通常需要数小时才能传递消息。
这就是您 json
所需要的
{
"content_available":true,
"to" : "l6rofh8dvAc:AP......BVhhXSYc3thtGklEzJzoZFGRMI7lBk4RhmcW",
"message_id": "1",
"priority" : "high", # Add this
"notification" :
{
...
},
}
您可以在此处阅读有关设置优先级的更多信息https://developers.google.com/cloud-messaging/concept-options#setting-the-priority-of-a-message
我是初学者 iOS 开发人员(所以..如果我犯了一个愚蠢的错误,我深表歉意)。 我已成功实施 GCM,插入时 运行 正常(运行 和 XCode)。但是当我从我的电脑上拔下我的设备时,它不再提示横幅。 所以,当 :
- 已插入 -> 打开应用程序时 -> JSON 收到
- 已插入 -> 当应用程序在后台时 -> 出现横幅
- 未插电 -> 打开应用程序时 -> JSON 收到
- 不插电 -> 当应用程序在后台时 -> 没有
我用这些JSON
{
"content_available":true,
"to" : "l6rofh8dvAc:AP......BVhhXSYc3thtGklEzJzoZFGRMI7lBk4RhmcW",
"message_id": "1",
"notification" :
{
"body" : "helloo!!",
"title" : "GCM",
"icon" : "",
"sound": "default",
"alert":"default",
"badge":"12",
"color": "#03A9F4",
},
"data":
{
"body":"Hello, How are you?",
"title":"Test"
}
}
我的JSON错了吗?还是我在 XCode 错过了什么? (我按照 中的示例 在 iOS 上设置 GCM 客户端应用程序 - 示例(稍作修改)。
您应该将消息的优先级设置为high
。您设置优先级的方式设置为低,APNS 在发送消息时优化电池,通常需要数小时才能传递消息。
这就是您 json
所需要的{
"content_available":true,
"to" : "l6rofh8dvAc:AP......BVhhXSYc3thtGklEzJzoZFGRMI7lBk4RhmcW",
"message_id": "1",
"priority" : "high", # Add this
"notification" :
{
...
},
}
您可以在此处阅读有关设置优先级的更多信息https://developers.google.com/cloud-messaging/concept-options#setting-the-priority-of-a-message