多个GoogleService-Info支持

时间:2016-08-02 19:19:59

标签: ios firebase

我将Dev和Prod计划注册为Firebase中的不同应用程序。我希望它们是分开的,每个都有唯一的捆绑ID。我使用#if dev来确定它是dev还是prod方案。如何使用专用的plist为该方案初始化firebase?

2 个答案:

答案 0 :(得分:5)

只需使用[FIRApp configureWithOptions:]

public static void ConfigureApp(IAppBuilder appBuilder)
    {                           
        appBuilder.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        appBuilder.UseCookieAuthentication(new CookieAuthenticationOptions());

        appBuilder.UseWsFederationAuthentication(
            new WsFederationAuthenticationOptions
            {
                Wtrealm = _realm,
                MetadataAddress = _acsXmlMetaDataUrl
            });

        // Configure Web API for self-host. 
        HttpConfiguration config = new HttpConfiguration();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        appBuilder.UseWebApi(config);
    }

答案 1 :(得分:1)

使用

var firebasePlist: String? = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")
if development == true{
firebasePlist = Bundle.main.path(forResource: "GoogleService-Info-DEV", ofType: "plist")
}
var options = FIROptions(contentsOfFile: firebasePlist)
FIRApp.configure(with: options)

但是当你想要使用DEV Google服务plist时,你必须有一个名为development的变量,其值为true,而你想使用常规GoogleService plist,则值为false