gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 05:12:13 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com