AppDelegate.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2021 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "AppDelegate.h"
  17. #import "SignInViewController.h"
  18. @import GoogleSignIn;
  19. @implementation AppDelegate
  20. #pragma mark Object life-cycle.
  21. - (BOOL)application:(UIApplication *)application
  22. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  23. // Restore any previous sign-in session at app launch before displaying main view. If the restore
  24. // succeeds, we'll have a currentUser and the view will be able to draw its UI for the signed-in
  25. // state. If the restore fails, currentUser will be nil and we'll draw the signed-out state
  26. // prompting the user to sign in.
  27. [GIDSignIn.sharedInstance restorePreviousSignInWithCallback:^(GIDGoogleUser * _Nullable user,
  28. NSError * _Nullable error) {
  29. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  30. SignInViewController *masterViewController =
  31. [[SignInViewController alloc] initWithNibName:@"SignInViewController" bundle:nil];
  32. self.navigationController =
  33. [[UINavigationController alloc] initWithRootViewController:masterViewController];
  34. self.window.rootViewController = self.navigationController;
  35. [self.window makeKeyAndVisible];
  36. }];
  37. return YES;
  38. }
  39. - (BOOL)application:(UIApplication *)app
  40. openURL:(NSURL *)url
  41. options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  42. return [GIDSignIn.sharedInstance handleURL:url];
  43. }
  44. @end