【问题标题】:Firebase cloud messaging for iOS: don't receive notifications from POST request (only from composer tool)适用于 iOS 的 Firebase 云消息传递:不接收来自 POST 请求的通知(仅来自 composer 工具)
【发布时间】:2018-05-29 15:16:51
【问题描述】:

我使用他们的快速入门教程和 API 文档为 iOS 设置 Firebase 云消息传递:https://firebase.google.com/docs/cloud-messaging/ios/first-message 我从 Firebase 作曲家工具向我的 iPhone 发送了消息,它是成功的。但我需要的下一步是接收通过常规 POST 请求发送的通知。我发现可以使用旧协议:https://firebase.google.com/docs/cloud-messaging/auth-server#authorize_legacy_protocol_send_requests 我尝试发送以下内容:

{ "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!"
  },
  "to" : "myIphoneTokenHere"
} 

通过带有我的 Firebase 项目授权密钥的邮递员并收到成功响应:

{
    "multicast_id": 5644065455367933439,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": [
        {
            "message_id": "0:1513338642327024%5529b926f9fd7ecd"
        }
    ]
}

但我的 iPhone 上没有通知,这与 composer 工具不同。 想知道我可以尝试什么来解决这个问题,我该如何调试出了什么问题?

【问题讨论】:

  • 请显示您用于处理传入消息的代码。该代码应该在您的AppDelegate 中。

标签: ios firebase-cloud-messaging


【解决方案1】:

通过将请求正文更改为:

{
"content_available": true,
"notification" : {
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message"}, "to" : "myIphoneTokenHere" }

【讨论】:

    猜你喜欢
    • 2017-05-05
    • 2022-07-20
    • 2021-08-04
    • 1970-01-01
    • 2016-09-22
    • 2020-01-02
    • 2020-07-16
    • 2020-06-16
    • 1970-01-01
    相关资源
    最近更新 更多