【问题标题】:FCM flutter enable notification vibrationFCM颤振启用通知振动
【发布时间】:2021-10-31 21:52:38
【问题描述】:

我正在为 Android 和 IOS 开发 Flutter 应用程序。我根据这个article为Android创建了通知渠道。

我的 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。问题是振动默认是禁用的。

如何开启安卓和IOS的通知振动功能?

【问题讨论】:

    标签: firebase flutter notifications firebase-cloud-messaging


    【解决方案1】:

    您可以将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
    }
    

    【讨论】:

    • 感谢@Victor Eronmosele。我刚刚在我的手机上检查了一些使用默认声音的应用程序,有些应用程序处于振动状态,有些没有。如何确保“默认”的声音共鸣?
    猜你喜欢
    • 2021-09-06
    • 2020-12-27
    • 2019-02-26
    • 2021-04-28
    • 2021-09-14
    • 2020-11-19
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多