【发布时间】:2019-06-29 11:03:51
【问题描述】:
我希望我的 Cloud Function 向特定主题发送推送通知,这很好用。但是,当我添加“徽章”字段时,会出现以下错误:
Unknown name "badge" at 'message.notification': Cannot find field.
如果我想为 iOS 设备指定一个徽章编号,我应该怎么做?我的代码如下所示:
exports.onAddLog = functions.database.ref("/NodesLog/{id}").onCreate((change, context) => {
const payload = {
"topic": "Channel123",
"notification": {
"title": "Test-Title",
"body": "Test-Body",
"badge": "1"
},
"data": {
"test": "test",
"notId": "123"
}
}
const promise : Promise<any> = admin.messaging().send(payload)
.catch(error => console.error("Error on send: " + error))
.then(sendSuccess => console.log("Notification send "))
.catch(() => console.error("What happened?"))
return promise;
})
【问题讨论】:
标签: ios firebase firebase-cloud-messaging