firebase - FCM flutter 启用通知振动

标签 firebase flutter notifications firebase-cloud-messaging

我正在为 Android 和 IOS 开发 Flutter 应用程序。我已经根据这个 article 创建了 Android 的通知 channel 。 .

我的 node.js 负载:

const payload = {
      notification: {
        title: "title",
      },
      android: {
        priority: "high",
        ttl: 60 * 60 * 1,
        notification: {
          channel_id: 'YO',
        },
      },
      apns: {
        payload: {
          aps: {
            sound: "sound_03.caf"
          }
        },
        headers: {
          "apns-collapse-id": "yo",
          "apns-priority": "10"
        }
      },
      priority: 10
    }

我的通知工作正常,适用于 Android 和 IOS。问题是默认情况下禁用振动。

如何为 Firebase Cloud Messaging 启用 Android 和 IOS 的通知振动?

最佳答案

您可以将 sound 属性设置为 default,以便在启用声音时使用默认声音,并在设备处于振动状态时振动。

您可以将有效负载更新为:

const payload = {
  notification: {
    title: "title",
    sound: "default"
  },
  android: {
    priority: "high",
    ttl: 60 * 60 * 1,
    notification: {
      channel_id: 'YO',
    },
  },
  apns: {
    payload: {
      aps: {
        sound: "default"
      }
    },
    headers: {
      "apns-collapse-id": "yo",
      "apns-priority": "10"
    }
  },
  priority: 10
}

关于firebase - FCM flutter 启用通知振动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69029951/

相关文章:

flutter - 在 Flutter Web 应用程序中更改屏幕尺寸

firebase - Firebase搜索查询返回空结果

Flutter:使自定义底栏出现时向上滑动

ruby-on-rails - 订阅 Rails 异常,使用 ActiveSupport::Notifications.subscribe

node.js - 将 Firebase 的第三方用户数据对象发布到服务器

swift - 在快照中迭代子项并在 Firebase 中的每个子项中获取值

android - Firebase Firestore Kotlin API 将数据导入自定义对象时出错 : None of the following functions can be called with the arguments supplied

FireBase 身份验证的好处

android - 如何以编程方式删除正在进行的通知?

android - 单击按钮后防止通知抽屉折叠