不同的GoogleService-Info.plist文件适用于ios和android中的开发和产品

不同的GoogleService-Info.plist文件适用于ios和android中的开发和产品,ios,react-native,react-native-android,react-native-ios,google-signin,Ios,React Native,React Native Android,React Native Ios,Google Signin,我正在使用google登录一个应用程序。我在后端安装了一个dev和一个prod google API项目 我想在我的react原生应用程序中使用单独的GoogleService-Info.plist for dev和prod 如何根据环境配置GoogleService-Info.plist?您需要根据环境进行配置 NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info&q

我正在使用google登录一个应用程序。我在后端安装了一个dev和一个prod google API项目

我想在我的react原生应用程序中使用单独的GoogleService-Info.plist for dev和prod


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

您需要根据环境进行配置

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];

如果您已将项目配置为 不需要在代码中配置任何内容

对于ANDROID,默认情况下,您可以设置3个环境

  • 发展
  • 释放
  • 谷歌游戏(制作)
  • ANDROID为上述环境提供单独的SHA-1密钥。 使用这些SHA-1键,您可以创建3个Oauth项目。现在您有了3个Oauth google项目,您可以使用项目的3个独立分支(dev、release、prod)进行配置

    对于IOS

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