【发布时间】: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