ios - 无法接收 FCM(推送通知 iOS)
问题描述
我通过React Native制作应用程序。几天前,我收到了FCM。但现在我不能。
客户端应用权限通知,我设置了 Xcode(capability)、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 ”
=======加法========
重新生成 APN 和设置,我可以收到通知。但是第二天,我无法收到通知。
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)检查证书是否已过期(不太可能),因为您提到它几天前仍在工作。
推荐阅读
- firebase - Firebase 的 scrypt 版本不提供与 save 相同的哈希值
- javascript - 如何将动态对象附加到 HTML 元素?
- redis - Redis 在行动 - 不公平的信号量
- windows - Firebase Unity 是否支持 Windows UWP 或 Windows 10 应用程序?
- firebase - Azure 和 FCM 之间的设备注册如何工作
- android - 从android中的视图中剪切一个形状
- reactjs - 在 React.js 中将对象添加到数组
- javascript - 两个 webpack 模块之间的重用函数
- c# - 并行处理列表中可用的项目
使用 Parallel.ForEach - php - Codeigniter 使用 site_url 发送 GET 参数?