【问题标题】:Firebase Cloud Messaging - how to add sound to APNFirebase 云消息传递 - 如何向 APN 添加声音
【发布时间】:2018-04-25 22:04:16
【问题描述】:

当使用HTTP v1 API 向iOS 设备发送APN 时,Apple documentation 声明如果apns-priority 设置为10,则

Notifications with this priority must trigger an alert, sound, or badge on the target device

documentation at Firebase 似乎建议添加到 apns JSON 对象:

只有在 JSON POST 中使用以下内容设置优先级时我才会成功:

"apns": {
            "headers": {
                "apns-priority": "10"
            }
        },

当我按照文档建议发布以下内容时:

...
"apns": {
            "headers": {
                "apns-priority": "10"
            },
            "payload": {
                "sound": "default"
            }
        },
...

a 400 - Bad Request 从 FCM 服务器返回。如果我排除 payload json 部分,则 POST 有效。

还尝试了以下方法:

...
"apns": {
            "headers": {
                "apns-priority": "10"
            },
            "sound": "default"
...

仍然收到 400 - 错误请求

如何在 SDK API JSON POST 中的 APN 上设置声音?默认声音就足够了。

【问题讨论】:

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


    【解决方案1】:

    声音对象必须是aps 对象的一部分:

    ...
    "apns": {
       "headers": {
           "apns-priority": "10"
        },
        "payload": {
            "aps": {
                "sound": "default"
            }
        }
     },
    ...
    

    【讨论】:

      【解决方案2】:

      根据您的 JSON,您似乎正在使用 HTTP v1 API。

      “apns”特定字典描述为here

      例如,为了播放默认声音:

      ...
      "apns": {
        "headers": {
          "apns-priority":"10"
        },
        "payload": {
          "sound":"default"
        },
      },
      ...
      

      【讨论】:

      • 感谢您的链接 - 但请参阅我的帖子编辑关于您的建议。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      相关资源
      最近更新 更多