【问题标题】:Different GoogleService-Info.plist files for dev and prod for ios and android in react-nativereact-native 中用于 ios 和 android 的 dev 和 prod 的不同 GoogleService-Info.plist 文件
【发布时间】:2021-01-04 06:53:04
【问题描述】:

我正在使用react-native-google-signin 的应用程序中使用谷歌登录。我在后端设置了一个 dev 和一个 prod google API 项目。

我想在我的 react-native 应用中为 dev 和 prod 使用单独的 GoogleService-Info.plist。

如何根据环境配置 GoogleService-Info.plist?

【问题讨论】:

    标签: ios react-native react-native-android react-native-ios google-signin


    【解决方案1】:

    您需要根据您的环境进行配置。

    NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
    
    #if DEV
        firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-DEV" ofType:@"plist"];
    #endif
    
    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebasePlist];
    [FIRApp configureWithOptions:options];
    

    【讨论】:

      【解决方案2】:

      如果您已使用https://console.developers.google.com 配置您的项目 无需在您的代码中配置任何内容。

      ANDROID默认可以设置3个环境

      1. 开发
      2. 发布
      3. Google Play(生产)

      ANDROID 为上述环境提供单独的 SHA-1 密钥。 使用这些 SHA-1 密钥,您可以创建 3 个 Oauth 项目。现在您有 3 个 Oauth google 项目,您可以使用项目的 3 个独立分支(dev、release、prod)进行配置。

      对于 IOS

      您可以根据需要创建任意数量的 Oauth google 项目。 只需根据构建时 ios 文件夹中的环境,保留您的 Oauth google 项目的 GoogleService-Info.plist。

      【讨论】:

        猜你喜欢
        • 2017-01-14
        • 1970-01-01
        • 2017-07-27
        • 1970-01-01
        • 2014-02-08
        • 2011-11-03
        • 2022-01-06
        • 2019-12-07
        • 2016-01-04
        相关资源
        最近更新 更多