iOS没有收到通过API发送的Firebase推送通知 [英] iOS not receiving Firebase Push Notification sent through the API

查看:145
本文介绍了iOS没有收到通过API发送的Firebase推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google的Firebase Cloud Messaging将推送通知发送到我的iOS和Android应用程序。通过云消息传递控制台发送的推送通知正常工作,但是当我通过API发送推送通知时,iOS应用程序仅在前台收到通知。在Android上,它正常工作(在前景和后台)。

I'm using Google's Firebase Cloud Messaging to send push-notifications to my iOS and Android applications. The push-notifications sent through the Cloud Messaging console work just as intended, however when I send a push-notification through the API, the iOS application only receives it when in foreground. On Android, it is working correctly (both in foreground and background).

阅读文档后,iOS系统会将通知对象传送到系统托盘,如预期的那样,显示身体消息。然而,这是行不通的。

Reading the documentation, the iOS system would then transfer the "notification" object to the system tray, as intended, showing the "body" message. However, this is not working.

以下是我发送的JSON的内容:
$ b $

Here's the content of the JSON I'm sending:

{
    "notification":
        {
            "body": "This a test notification"
        },
        "to":"eQ5tiy0cMZ8:APA91bE4CCjDXEJxEIRxKY18pXMMGUBqY1OKJFhVbR-pNhvQjJuhPcc7pXa..."
}

有没有人使用Firebase云消息最近?谢谢。

Did anyone have similar problems using Firebase Cloud Messaging recently? Thank you.

推荐答案

我设法解决这个问题得益于这个答案: https://stackoverflow.com/a/37550067/516338

I managed to fix the problem thanks to this answer: https://stackoverflow.com/a/37550067/516338

基本上,尽管不在文档中,但您必须在iOS上将priority字段设置为high,如下所示:

Basically, although NOT in the documents, you have to set the "priority" field to "high" on iOS, like this:

{   
  "to": "cHPpZ_s14EA:APA91bG56znW...",
  "priority": "high",
  "notification" : {
    "body" : "hello!",
    "title": "afruz",
    "sound": "default"
  }
}  

这篇关于iOS没有收到通过API发送的Firebase推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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