【问题标题】:firebase.notifications() is throwing error in react-native-firebasefirebase.notifications() 在 react-native-firebase 中抛出错误
【发布时间】:2018-06-14 17:27:49
【问题描述】:

我已成功地将 firebase 集成到我的移动应用程序中。现在我正在android上测试它。我成功收到通知。我的下一步是在应用程序处于前台和后台时触发事件并读取数据。对于这件事,我看到了文档并使用了firebase.notifications().displayNotification()。但它正在抛出错误。

确保您有:

1) 安装了所需的 Firebase Android SDK 依赖项 'com.google.firebase:firebase-notifications' 在你的 'android/app/build.gradle' 文件。

2) 导入 'io.invertase.firebase.notifications.RNFirebaseNotificationsPackage' 'MainApplication.java' 文件中的模块。 3)添加了“新 RN'getPackages()' 内的 RNFirebaseNotificationsPackage()' 行 方法列表。

【问题讨论】:

  • 我试过这样做,但在 firebase 文档中没有像 com.google.firebase:firebase-notifications 这样的东西。
  • 我已经在 android/app/gradle.build 中编译 compile 'com.google.firebase:firebase-messaging:11.0.4'
  • Core 仅用于主包,但您仍需要在项目中根据需要添加其他包(例如 Firestore、存储、消息传递)。

标签: android firebase react-native-firebase


【解决方案1】:

听起来您需要按照this page 上的说明安装通知依赖项。他们最近重写了 react-native-firebase 的通知部分,因此您的用例可能也需要这样做。

【讨论】:

  • 是的,这就是解决方案。我不知道我是怎么错过的。还是谢谢
  • 5.x.x 版的 Android 通知包链接 https://rnfirebase.io/docs/v5.x.x/notifications/android
  • 更新了 5.x 链接 :)
  • @NoahAllen 嘿,我在文档中提到了相同的设置,但一次又一次地收到此错误。我正在使用 react-native-firebase v5。
  • @NoahAllen 我正在使用 5.5.7,但仍然出现此错误,太糟糕了,我无法更新到 v6,因为我需要 iOS/Android 的推送通知。任何的想法?我超级卡住了,一直在抛出那个错误。
【解决方案2】:

我遇到了同样的错误错误:您试图通过使用 invertase firebasev6 调用 firebase.notifications() 来使用未安装在您的 Android 项目上的 firebase 模块...

经过几项研究,我发现通知应该在 rnfirebase.io 中实现,即 firebase v5 和更低版本

因此,invertase 决定不在他们的 firebase 包 v6 中使用通知。

要使用通知,您可以在文档处于 alpha 版本时参考他们的通知包,或者您可以使用 wix/react-native-notifications 等...这是额外的包

【讨论】:

  • 你现在能帮我处理 v6 并响应原生 v0.63.3 吗?
猜你喜欢
  • 1970-01-01
  • 2021-05-29
  • 2020-06-07
  • 1970-01-01
  • 2016-03-29
  • 2020-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多