我希望我的云函数能够向特定主题发送推送通知,这一点已经很好地实现了。但是,当我添加“badge”字段时,就会出现以下错误:
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;
})