iOS通过UNNotificationInterruptionLevel
区分消息。我希望通过FCM发送的消息具有time-sensitive
interruption-level
。
这是否等同于在FCM中以高优先级发送消息?不幸的是,我从文档中看不太清楚。
中断级别由系统自动处理,而不是由FCM处理。这与高优先级不同。
您应该能够按照Apple的文档原样使用它。FCM支持在有效负载中向下传递中断级别。
我通过在我的firebase控制台文件中包含以下有效负载来实现这一点:
var message = {
notification: {
title: "Notification Title",
body: `${initiatedUsername} sent you message`,
},
"data": {
"target_exec":"messaging"
},
"apns": {
"payload": {
"aps": {
"alert": {
"title": "Notification Title",
"body": `${initiatedUsername} sent you a message`
},
"badge": 1,
"sound": "default",
"interruption-level": "time-sensitive"
}
}
},
token: fcmToken,
};
如果你想向topic发送消息,也可以将token属性更改为topic。
希望这能帮助到这里的人!
旧的FCM不支持中断级别。您应该迁移到Firebase云消息传递API (V1)