[英]FCM NodeJS Push Notification not working on iOS
我在 iOS 和 Android 上尋找 firebase 的通知。 對於 App,我使用 React Native,對於后端,我使用 NodeJS。 我已經使用 FCM NodeJS 庫,當我嘗試向 Android(模擬器)發送通知時它成功,但是當我在 iOS(模擬器)上發送通知時它不起作用
我的nodeJS代碼:
const FCM = require('fcm-node');
const fcm = new FCM(process.env.FIREBASE_SERVER_KEY);
exports.pushNotifNew = (req, res, next) => {
var message = {
to: 'futyaqvqcEyqkcs4HNFXzH:APA91bFg',
notification: {
title: 'Title of your push notification',
body: 'Body of your push notification'
},
data: {
my_key: 'my value',
my_another_key: 'my another value'
}
};
fcm.send(message, function(err, response){
if (err) {
console.log("Something has gone wrong!");
} else {
console.log("Successfully sent with response: ", response);
}
});
}
后端或 React Native 中是否有任何必需的代碼或屬性來向 iOS 發送通知? 但是,當我使用 testfcm.com 時,它適用於 iOS。 之前謝謝。
像下面那樣做你的通知正文
{
to: validDeviceRegistrationToken,
data: { //some data object (optional)
url: 'news',
foo:'fooooooooooooo',
bar:'bar bar bar'
},
priority: 'high',//imp
content_available: true,
notification: { //notification object
title: 'HELLO', body: 'World!', sound : "default", badge: "1"
}
};
通知 object 是 iOS 的提示
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.