【问题标题】:Firebase Functions Not Sending Notification To DeviceFirebase 函数未向设备发送通知
【发布时间】:2023-03-20 18:41:02
【问题描述】:

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

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

【问题讨论】:

    标签: javascript node.js firebase


    【解决方案1】:

    尝试添加

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

    前段时间我也遇到过同样的问题,希望对你有帮助。

    【讨论】:

    • 现在每次都在发送通知!谢谢!
    猜你喜欢
    • 2019-05-09
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 2015-09-02
    • 2019-06-13
    • 2017-12-07
    • 2016-11-09
    相关资源
    最近更新 更多