尝试通过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.")
}
});
});