1
我可以将推送通知从Firebase Console Notifications
发送到我的iOS设备,它可以完美地作为前台和后台的应用程序。Firebase-admin不发送iOS APN通知
当我尝试使用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);
});
}
你觉得这是怎么回事?你知道一些方法来记录这个问题吗?
谢谢!有两次失败。首先,你说的那个。其次,firebase json很糟糕:(开发太多小时... – Georgevik