Skip to content

Commit

Permalink
Merge pull request arnesson#880 from chrisid/issue866
Browse files Browse the repository at this point in the history
setup [FIRapp configureWithOptions] passing Google .plist
  • Loading branch information
briantq authored Oct 3, 2018
2 parents 1dd3b49 + 78bd942 commit 81601bb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ios/AppDelegate+FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,22 @@ - (NSNumber *)applicationInBackground {
- (BOOL)application:(UIApplication *)application swizzledDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self application:application swizzledDidFinishLaunchingWithOptions:launchOptions];

if (![FIRApp defaultApp]) {
// get GoogleService-Info.plist file path
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];

// if file is successfully found, use it
if(filePath){
NSLog(@"GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]");
// create firebase configure options passing .plist as content
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];

// configure FIRApp with options
[FIRApp configureWithOptions:options];
}

// no .plist found, try default App
if (![FIRApp defaultApp] && !filePath) {
NSLog(@"GoogleService-Info.plist NOT FOUND, setup: [FIRApp defaultApp]");
[FIRApp configure];
}

Expand All @@ -65,7 +80,7 @@ - (BOOL)application:(UIApplication *)application swizzledDidFinishLaunchingWithO
self.applicationInBackground = @(YES);

return YES;
}
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
[self connectToFcm];
Expand Down

0 comments on commit 81601bb

Please sign in to comment.