gpt4 book ai didi

ios - iOS 版 GCM 在不调试时不显示

转载 作者:行者123 更新时间:2023-11-28 21:39:49 24 4
gpt4 key购买 nike

我是一名 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 中遗漏了什么? (我遵循了 Setting up a GCM Client App on iOS - Sample 中的示例(几乎没有修改)。

最佳答案

您应该将消息的优先级设置为。您设置优先级的方式设置为低,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 - iOS 版 GCM 在不调试时不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32626434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com