Zarejestrowałem plany Dev i Prod jako różneaplikacje w Firebase. Chcę, żeby były oddzielne, Każda ma unikalny identyfikator pakietu. Używam #if dev, aby określić, czy jest to program dev lub prod. Jak mogę zainicjować firepo z dedykowanym plistem dla tego schematu?
Odpowiedzi:
5 dla odpowiedzi № 1Wystarczy użyć [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];
1 dla odpowiedzi nr 2
posługiwać się
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)
ale będziesz musiał mieć zmienną o nazwie development z wartością true, jeśli chcesz użyć pliku plikowego DEV GoogleService, a wartość false oznacza, że chcesz użyć zwykłego pliku plikowego GoogleService