繁体   English   中英

Firebase 函数未向设备发送通知

[英]Firebase Functions Not Sending Notification To Device

我的 Firebase 函数中有一些代码将通知放在一起并将其发送到用户的设备。 但是在它向令牌发送一个通知并被传递之后,它发送的未来通知不会通过。 我知道这不是客户端,我所做的只是打印出数据。 这是我发送通知的方式:

    admin.messaging().sendToDevice(recipientToken, payload)
    .then(function (response) {
        console.log("Successfully sent message:", response);
    })
    .catch(function (error) {
        console.log("Error sending message. Cause: ", error);
    });

我是否缺少某种参数或其他东西?

尝试添加

 const options = {
    priority: "high",
}; 

并把它放在这里:

  admin.messaging().sendToDevice(recipientToken, payload, options)
.then(function (response) {
    console.log("Successfully sent message:", response);
})
.catch(function (error) {
    console.log("Error sending message. Cause: ", error);
});

不久前我遇到了同样的问题,所以我希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM