![](/img/trans.png)
[英]iOS cannot receive push notification from FCM on Cordova project (2018)
[英]Cannot receive FCM (Push Notification iOS)
我通過React Native制作應用程序。 幾天前,我能夠收到FCM 。 但現在我不能。
客戶端應用權限通知,我設置了 Xcode(功能)、firebase 和 Apple Developer(APNs 設置)。
console.log 告訴我成功。
但我無法收到通知。 雖然前幾天我可以。
這是firebase中的錯誤嗎?
我不知道原因,請幫幫我m(_ _)m
========環境==========
Xcode 版本11.3 "react-native-firebase": " ^5.6.0 " "react-native": " 0.61.5 " " firebase -admin": " ^8.9.0 "
========補充========
重新生成 APNs 和設置,我可以收到通知。 但第二天,我無法收到通知。
APNs 只在一天內有效???
最有可能的是,在您的 Firebase 控制台中,目前有資格參加此活動的潛在用戶數為 0。
“基於大約 0 個注冊接收通知的用戶進行估計。由於設備不活動,一些目標用戶將看不到消息。對於重復性活動,估計值僅用於初始發送。”
可能的解決方案:
1)如果是這樣(0個用戶注冊)
--> 檢查是否收到fcmToken。
getFcmToken = async () => {
const fcmToken = await firebase.messaging().getToken();
if (fcmToken) {
console.log(fcmToken);
this.showAlert(‘Your Firebase Token is:’, fcmToken);
} else {
this.showAlert(‘Failed’, ‘No token received’);
}
}
2) 如果數字不為零
--> 很可能您的應用程序在前台打開並且未顯示通知。
--> 嘗試鎖定你的 iPhone 屏幕並出現通知,否則嘗試處理應用程序在前台的情況
messageListener = async () => {
this.notificationListener = firebase.notifications().onNotification((notification) => {
const { title, body } = notification;
this.showAlert(title, body);
});
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
const { title, body } = notificationOpen.notification;
this.showAlert(title, body);
});
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
const { title, body } = notificationOpen.notification;
this.showAlert(title, body);
}
this.messageListener = firebase.messaging().onMessage((message) => {
console.log(JSON.stringify(message));
});
}
3)檢查證書是否已過期(不太可能),因為您在幾天前提到它仍在工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.