![](/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.