【发布时间】:2023-01-16 19:43:20
【问题描述】:
我有一个带有 React Native 的移动应用程序并且可以正常工作。我想向该应用程序添加通知功能。
我安装了 firebase/app、firebase/messaging 和 @notifiee 以便能够发送通知。安装这些包后,我可以在 android 模拟器上构建我的应用程序,但我在控制台上遇到这样的错误:
ERROR Error: Notifee native module not found.
LOG Running "myMobileApp" with {"rootTag":1}
ERROR Invariant Violation: "myMobileApp" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
我在 Ubuntu 20.04.4 LTS 上使用 Visual Studio Code、Android Studio Emulator 和 JDK 11。
我的 package.json 中的相关包:
"dependencies": {
...
"@notifee/react-native": "^5.3.0",
"@react-native-firebase/app": "^14.11.0",
"@react-native-firebase/messaging": "^14.11.0",
"react": "16.13.1",
"react-native": "0.63.4",
...
},
【问题讨论】:
-
这似乎在安装阶段没有链接相应的本机模块。你使用 Expo 还是 React Native CLI
-
@ShyPenguin 我使用 React Native CLI
-
尝试清理以前的 android 构建
cd android && ./gradlew clean -
嘿nevidev。可能不是这种情况,但您是否同时在
ios中运行它?如果是,请记住在 ios 和 android 中构建它并同步pods
标签: android firebase react-native push-notification