ios - React Native iOS 的无效注册
问题描述
我正在构建 React Native App。我使用了react-native-notification库来添加通知功能。
我的 Andriod 应用程序可以生成令牌并从 firebase 接收通知,但对于 iOS 应用程序,会生成令牌,但是当向此令牌 id 发送消息时没有发生任何事情,而是出现错误。
“错误”:“无效注册”
await NotificationsIOS.addEventListener('remoteNotificationsRegistered', onPushRegistered);
await NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', onPushRegistrationFailed);
await NotificationsIOS.requestPermissions();
function onPushRegistered(deviceToken) {
// TODO: Send the token to my server so it could send back push notifications...
console.log("Device Token Received", deviceToken);
}
我使用此代码在生成令牌的 iOS 上获取设备令牌,但我认为它不是 vlaid FCM 令牌。45f41b17e16b5970fe35.......8222b01289580bae87ba35d2b2bc72b
{
"data": {
"title": "sample Title",
"content": "sample text",
"key": "Im the key"
},
"to": "ce4a46370d7c4060b0a4dd.........47de821d0bc1767f124a2fa157afe"
}
但是当我将 FCM 消息发送到这个令牌 id 时,它给了我上面的错误。我还将 APN 的证书添加到了 firebase。我可以在 ios 上使用这个库生成本地通知,远程安卓通知也可以正常工作。请帮助我修复它,因为我不想使用任何其他库,谢谢。
解决方案
推荐阅读
- javascript - 静态文件不在一个模板上加载,而是在另一个模板上加载
- javascript - Vue 3 refs 在渲染函数中未定义
- android - Drawable在Android App中不显示角落
- curl - 为什么当我尝试从 LinkedIn 检索个人的电子邮件地址时 curl 不起作用
- ssh - scp 显示权限被拒绝但 ssh 正在工作
- java - 如何在构造函数上应用方法
- vba - 有没有办法在 PowerPoint VBA 中使用形状的 ID 来确定它的颜色?
- amazon-web-services - 在无服务器中创建 S3 存储桶策略 - 发生错误:BucketPolicy - 策略语法无效
- angular - 发布时的 Net Core 3.1 ISpaStaticFileProvider 问题
- python - Python3 .intersection() 函数在运行时的输入顺序是否重要?