【问题标题】:Firebase Cloud Messaging Ignoring APNS keyFirebase 云消息传递忽略 APNS 密钥
【发布时间】:2018-08-25 11:45:40
【问题描述】:

我正在尝试使用此处所述的 apns 密钥向我的设备发送通知:https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig

推送通知确实到达,但标题未被覆盖。当我省略 notification 键时,只有在添加 content_available: true 选项时才会(在后台)发送通知。

我的身体是这样的:

{
    "to" : <TOKEN>,
    "apns" : {
        "payload" : {
            "aps" : {
                "alert" : "Does not work",
                "badge" : 1,
                "sound" : "bingbong.aiff"
            }
        }
    } 
    "notification" : { 
        "body" : "Works" 
    }
}

无论我尝试什么组合,Firebase 似乎都忽略了 apns 键。我做错了什么?

【问题讨论】:

  • 它是如何为您解决的? (假设它最终对你有用)
  • 我最后只用了通知键
  • 有人找到解决办法了吗?

标签: firebase apple-push-notifications firebase-cloud-messaging


【解决方案1】:

您正在使用旧版 API 发送推送通知(不是 V1)。 Legacy API 不支持额外的密钥,如 Android 或 APNs。

所以你有两个选择:

  1. 继续使用旧版 API,这里是它的协议描述:https://firebase.google.com/docs/cloud-messaging/http-server-ref 请注意,您将无法使用特定的 Android 或 APNs 密钥。
  2. 移至 API v1。它允许您使用所有密钥,但需要为 OAuth2 设置服务器。 https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig

【讨论】:

    猜你喜欢
    • 2016-10-10
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 2022-06-11
    • 1970-01-01
    • 1970-01-01
    • 2022-06-21
    • 1970-01-01
    相关资源
    最近更新 更多