【发布时间】:2018-06-20 05:51:42
【问题描述】:
尝试通过 Firebase 云功能发送远程推送通知。我一直关注的资源通过sendToDevice 方法实现了这一点,该方法将字符串作为参数。来自 GitHub 的资源称其为“设备通知令牌”,当用户同意在应用程序中接收通知时会检索该令牌。 Firebase 称其为“来自客户端 FCM SDK 的注册令牌”。这里的输入应该是什么,以及如何检索它?
// Send notification to device via firebase cloud messaging.
// https://firebase.google.com/docs/cloud-messaging/admin/send-messages
// https://github.com/firebase/functions-samples/blob/master/fcm-notifications/functions/index.js
//
admin.messaging().sendToDevice(request.query.tokenId, payload).then(response => {
response.results.forEach((result, index) => {
const error = result.error
if (error) {
console.log("Failure sending notification.")
}
});
});
【问题讨论】:
标签: node.js firebase firebase-cloud-messaging google-cloud-functions