首页 > 解决方案 > 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 上使用这个库生成本地通知,远程安卓通知也可以正常工作。请帮助我修复它,因为我不想使用任何其他库,谢谢。

标签: iosfirebasereact-nativefirebase-cloud-messagingfirebase-notifications

解决方案


推荐阅读