iOS 未收到通过 API 发送的 Firebase 推送通知
iOS not receiving Firebase Push Notification sent through the API
我正在使用 Google 的 Firebase 云消息传递向我的 iOS 和 Android 应用程序发送推送通知。通过云消息传递控制台发送的推送通知按预期工作,但是当我通过 API 发送推送通知时,iOS 应用程序仅在前台接收它。在 Android,它工作正常(在前台和后台)。
阅读文档后,iOS 系统会按预期将 "notification" 对象传输到系统托盘,并显示 "body" 消息。但是,这不起作用。
这是我要发送的 JSON 的内容:
{
"notification":
{
"body": "This a test notification"
},
"to":"eQ5tiy0cMZ8:APA91bE4CCjDXEJxEIRxKY18pXMMGUBqY1OKJFhVbR-pNhvQjJuhPcc7pXa..."
}
有没有人最近在使用 Firebase Cloud Messaging 时遇到过类似的问题?谢谢。
由于这个答案,我设法解决了问题:
基本上,虽然不在文档中,但您必须在 iOS 上将 "priority" 字段设置为 "high",如下所示:
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}
我正在使用 Google 的 Firebase 云消息传递向我的 iOS 和 Android 应用程序发送推送通知。通过云消息传递控制台发送的推送通知按预期工作,但是当我通过 API 发送推送通知时,iOS 应用程序仅在前台接收它。在 Android,它工作正常(在前台和后台)。
阅读文档后,iOS 系统会按预期将 "notification" 对象传输到系统托盘,并显示 "body" 消息。但是,这不起作用。
这是我要发送的 JSON 的内容:
{
"notification":
{
"body": "This a test notification"
},
"to":"eQ5tiy0cMZ8:APA91bE4CCjDXEJxEIRxKY18pXMMGUBqY1OKJFhVbR-pNhvQjJuhPcc7pXa..."
}
有没有人最近在使用 Firebase Cloud Messaging 时遇到过类似的问题?谢谢。
由于这个答案,我设法解决了问题:
基本上,虽然不在文档中,但您必须在 iOS 上将 "priority" 字段设置为 "high",如下所示:
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}