【问题标题】:Sound and vibration with FCM notification on iOS?iOS 上 FCM 通知的声音和振动?
【发布时间】:2019-11-21 20:51:49
【问题描述】:

我正在使用 Firebase Cloud Messaging 为我的 iOS 应用发送通知。我想在设备收到通知时添加振动和声音。我为消息尝试了以下结构:

var message = {

            "notification": {
              "title":"Ma Cherie",
              "body":messageText
            },
            "sound":"default"
            topic: topic
  };

但我收到以下错误:

Error sending message: { Error: Invalid JSON payload received. Unknown name "sound" at 'message.notification': Cannot find field.

我也试过了:

var message = {

            "notification": {
              "title":"Ma Cherie",
              "body":messageText
            },
            "apns": {
                 "payload": {
                     "aps": {
                        "sound": "default"
                     }
                 }
            },
            topic: topic
  };

但我得到同样的错误。如何为通知添加声音(以及振动和徽章)?

【问题讨论】:

    标签: ios swift firebase firebase-cloud-messaging google-cloud-messaging


    【解决方案1】:

    尝试替换

     "sound":"default"
    

    "ios": { "notification": { "sound": 'default' } }
    

    我在 android 上遇到了类似的问题,这对我有用。 详情请参考Jaime's Post

    【讨论】:

    • 链接的帖子字面意思是说他已经做了什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    相关资源
    最近更新 更多