【发布时间】:2017-06-21 19:03:35
【问题描述】:
我可以将来自Firebase Console Notifications 的推送通知发送到我的iOS 设备,它可以完美地作为前台和后台的应用程序。
当我尝试使用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);
});
}
你认为它正在发生什么?你知道一些记录问题的方法吗?
【问题讨论】:
标签: ios firebase push-notification firebase-cloud-messaging firebase-admin