Support for multiple GoogleService-Info services

I registered my Dev and Prod schemas as different applications in Firebase. I want them to be separate, each has a unique package identifier. I use #if dev to determine if it is a dev or a prod schema. How can I initialize firebase with dedicated plist for this circuit?

+4
source share
2 answers

Just use [FIRApp configureWithOptions:]

NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];

#if STAGING
    firebasePlist = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-DEV" ofType:@"plist"];
#endif

FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebasePlist];
[FIRApp configureWithOptions:options];
+5
source

use

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)

but you will need to have a variable named development with a value of true if you want to use pls dev GoogleService and false if you want to use the regular tool GoogleService

+1

Source: https://habr.com/ru/post/1649956/


All Articles