ios - 无法接收 FCM(推送通知 iOS)

标签 ios firebase react-native

我通过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

======添加========

正在重新生成 APN 并设置,我可以收到通知。 但第二天我就收不到通知了。

APN 的有效期只有一天???

最佳答案

目前您的 Firebase 控制台中符合此广告系列资格的潜在用户数量很可能为 0。

“根据大约 0 名注册接收通知的用户进行估算。由于设备不活动,一些目标用户将看不到该消息。对于定期营销事件,估算值仅适用于初次发送。”

enter image description here

可能的解决方案:

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)检查证书是否已过期(不太可能),因为您提到几天前它仍然有效。

关于ios - 无法接收 FCM(推送通知 iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59574873/

相关文章:

reactjs - 没有可用的安全区域插入值。确保在应用顶部呈现 `<SafeAreaProvider>`。 - 我该如何解决这个错误?

ios - 推送通知声音不起作用

iphone - 重新配置动态库

ios - 具有 "More"按钮样式的 UIBarButtonItem

android - 如何安排每月第一天执行的任务并更新 Firebase 实时数据库中的值

swift - 协议(protocol)扩展不适用于 RCT_EXPORT_VIEW_PROPERTY?

iphone - 如何将使用iOS SDK拍摄的照片添加到用户的相机胶卷中?

Firebase webpack+babel 函数未部署

node.js - 仅将 worker dyno 部署到 heroku(用于 firebase-queue)

android - react Native TextInput 数字键盘在 android 上没有正确显示