簡體   English   中英

Firebase-admin不會發送iOS APN通知

[英]Firebase-admin doesn't send iOS APN notification

我可以將Firebase Console Notifications推送通知發送到我的iOS設備,它可以很好地成為前台和后台的應用程序。

當我嘗試使用Firebase-admin by NodeJS使用Firebase-admin by NodeJS發送它們時,它只適用於應用程序處於前台時,后台沒有任何反應。

我認為FCM-APN之間的通信很好,因為它適用於控制台。

這是我的NodeJS代碼:

function sendFCM(registration_ids, data, collapseKey) {

    const options = {
        priority: "high",
        collapseKey : collapseKey,
        contentAvailable : true,
        timeToLive: 60 * 60 * 24
    };

    const payload = {
        data: data,
        notification: {
            title: "My title",
            text: "My description",
            sound : "default"
        }
    }

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

你覺得它發生了什么? 你知道一些記錄問題的方法嗎?

服務器協議文檔指示通知文本的鍵是body ,而不是text 看看這種變化是否有所不同:

const payload = {
    data: data,
    notification: {
        title: "My title",
        body: "My description", // <= CHANGE
        sound : "default"
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM