【问题标题】:how to play custom notification sound in ios push notification using FCM如何使用 FCM 在 ios 推送通知中播放自定义通知声音
【发布时间】:2019-11-21 10:52:20
【问题描述】:

我正在使用 FCM 从服务器向 iOS 设备发送推送通知,但我成功收到通知但无法播放自定义通知声音。

这是我的有效载荷

{
    "to":"myToken",
    "notification":{
        "title":"new message",
        "body":"Hello World!",
        "sound":"tweet_sent.caf",
        "badge": 3
    }
}

注意:我还将“tweet_sent.caf”文件添加到 Xcode 包中

【问题讨论】:

标签: ios node.js swift firebase apple-push-notifications


【解决方案1】:

请将notification 键替换为aps,例如:

{
    "to":"myToken",
    "aps":{
        "title":"new message",
        "body":"Hello World!",
        "sound":"tweet_sent.caf",
        "badge": 3
    }
}

并将声音 tweet_sent.caf 文件添加到您的项目资源位置。

【讨论】:

【解决方案2】:

感谢您的回答和cmets

在构建阶段(Xcode)添加通知文件后,现在可以正常工作了。

参考:Playing a custom sound on receiving a remote push notification on iOS 12 from FCM

【讨论】:

    猜你喜欢
    • 2022-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    • 2017-01-16
    • 1970-01-01
    • 2019-09-02
    相关资源
    最近更新 更多