繁体   English   中英

混淆将 react-native-firebase 与 Expo 集成

[英]Confusion integrating react-native-firebase with Expo

我是 React Native 开发的新手,我正在为我使用 Expo 和 Firebase 构建的跨平台应用程序制作开发环境。

我正在尝试将 react-native-firebase 与 Expo 集成,因为这是我可以使用 Firebase 的“App Check”功能的唯一方式。 我想要一个托管工作流,我不必接触本机代码并使用 EAS 开发构建。

我已尝试使用以下文章设置我的环境,但它让我对某些事情感到困惑 -如何将我的应用程序连接到 firebase? 我是使用标准的 web JS SDK,还是我应该使用其他东西?

我查看了有关 expo 的 react-native-firebase文档,但没有帮助。

同样令人困惑的是:当我试图在 firebase 控制台上将 firebase 添加到我的 android 应用程序时,它提到将 firebase SDK 添加到 build.gradle 文件 - 我的项目没有。 那么我的设置中是否遗漏了一个步骤?

如果有任何帮助,以下是我到目前为止为我的项目采取的步骤:

1.) Created app with npx create-expo-app

2.) npm install -g eas-cli

3.) npx expo install expo-dev-client

 eas build 

4.) npx install @react-native-firebase/app

5.) Set up a project on firebase. Download google-services.json and GoogleService-Info.plist, and add them to the root of my expo project

6.) Configure app.json as follows:

    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "supportsTablet": true,
      "bundleIdentifier": "com.******.testapp"
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.******.testapp"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [ "@react-native-firebase/app"],

Gradle是移动应用项目常用的构建工具。 但是,由于您使用的是 Expo,因此 Expo 是您的构建工具,而不是 Gradle。

在您的app.json文件中,您可以看到那里的配置提到./GoogleService-Info.plist./google-services.json 这些是在您注册iOSAndroid应用程序后由 Firebase 控制台生成的配置文件。

可以按照这些说明重新下载它们。

  1. Go 到 Firebase 控制台中的项目设置
  2. 您的应用卡片中,select 是您需要配置文件的应用的捆绑包 ID/包名称。
  3. 单击GoogleService-Info.plistgoogle-services.json的下载链接(视情况而定)。
  4. 将文件保存到项目的根目录,确保只有最新下载的配置文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM