[英]FCM flutter enable notification vibration
我正在为 Android 和 IOS 开发一个 Flutter 应用程序。我已经根据这篇文章为 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 使用,我的通知工作正常。 问题是默认情况下禁用振动。
如何为Firebase云消息启用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
}
对我来说,我只需要将它添加到消息负载的notification
部分。
下面是它在 Typescript 中的样子(但消息 JSON 才是最重要的)。
let tokens = ...
let message = {
message: {
notification: {
title: title,
body: body,
sound: 'default', // <----- All I needed
},
data: {
...
},
}
}
firebase.messaging().sendToDevice(tokens, message)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.