简体   繁体   English

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

[英]Cannot receive FCM (Push Notification iOS)

I make app by React Native .我通过React Native制作应用程序。 Few days ago,I was able to receive FCM .几天前,我能够收到FCM But now I cannot.但现在我不能。

Client app permissions notification, I set Xcode(capability),firebase and Apple Developer(APNs setting).客户端应用权限通知,我设置了 Xcode(功能)、firebase 和 Apple Developer(APNs 设置)。

And console.log tells me success. console.log 告诉我成功。

But I cannot receive notification.但我无法收到通知。 Although few days ago I could.虽然前几天我可以。

Is this error in firebase??这是firebase中的错误吗?

I don't know cause, please help me m(_ _)m我不知道原因,请帮帮我m(_ _)m

=======environment========== ========环境==========

Xcode Version 11.3 "react-native-firebase": " ^5.6.0 " "react-native": " 0.61.5 " "firebase-admin": " ^8.9.0 " Xcode 版本11.3 "react-native-firebase": " ^5.6.0 " "react-native": " 0.61.5 " " firebase -admin": " ^8.9.0 "

=======addition======== ========补充========

Regenerating APNs and setting, I could receive notification.重新生成 APNs 和设置,我可以收到通知。 But next day, I couldn't receive notification.但第二天,我无法收到通知。

APNs is valid in only one day??? APNs 只在一天内有效???

Most probably, in your Firebase console number of potential users are eligible for this campaign is 0 currently.最有可能的是,在您的 Firebase 控制台中,目前有资格参加此活动的潜在用户数为 0。

"Estimate based on approximately 0 users who are registered to receive notifications. Some targeted users will not see the message due to device inactivity. For recurring campaigns, estimate is for initial send only." “基于大约 0 个注册接收通知的用户进行估计。由于设备不活动,一些目标用户将看不到消息。对于重复性活动,估计值仅用于初始发送。”

在此处输入图片说明

Possible solution:可能的解决方案:

1) If that's the case (0 users are registered) 1)如果是这样(0个用户注册)

--> Check if the fcmToken is received. --> 检查是否收到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) If the number is not zero 2) 如果数字不为零

--> Most probably your app is opened in foreground and the notification is not displayed. --> 很可能您的应用程序在前台打开并且未显示通知。

--> Try to lock your iPhone screen and the notification will appear, else try to handle it which the app is in foreground --> 尝试锁定你的 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) Check if the cert has expired (unlikely) since you mentioned that it's still working a few days back. 3)检查证书是否已过期(不太可能),因为您在几天前提到它仍在工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM