我的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);
});


不久前我遇到了同样的问题,因此希望对您有所帮助。

关于javascript - Firebase功能不向设备发送通知,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59217818/

10-10 01:08
查看更多