如何使用 FCM 发送推送通知以响应本机 android 应用程序

How to send push notification to react native android app using FCM

我正在尝试构建带有 firebase 推送通知的 react native(0.59.9) android 应用程序(FCM - ^16.2.4)。这个文档我用过https://github.com/evollu/react-native-fcm! .添加 google-service.json 文件和 gradle 依赖项后,出现错误。

Task :react-native-fcm:generateDebugBuildConfig FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':react-native-fcm:generateDebugBuildConfig'. Unable to delete directory '.......\node_modules\react-native-fcm\android\build\generated\source\buildConfig\debug\com\evollu\react' after 10 attempts

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

我认为您要安装错误的组件。 当然首先删除你当前的 react-native-fcm 组件。然后按照以下步骤在 react native 上安装 firebase 就足够了:

https://rnfirebase.io/docs/v5.x.x/installation/initial-setup

然后继续此 link 以配置 android:

https://rnfirebase.io/docs/v5.x.x/installation/android

另外这个link是一个很好的教程:

https://medium.com/@anum.amin/react-native-integrating-push-notifications-using-fcm-349fff071591