AppDelegate.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // DO NOT USE THIS CLIENT ID. IT WILL NOT WORK FOR YOUR APP.
  21. // Please use the client ID created for you by Google.
  22. static NSString * const kClientID =
  23. @"589453917038-qaoga89fitj2ukrsq27ko56fimmojac6.apps.googleusercontent.com";
  24. #pragma mark Object life-cycle.
  25. - (BOOL)application:(UIApplication *)application
  26. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  27. // Set app's client ID for |GIDSignIn|.
  28. [GIDSignIn sharedInstance].clientID = kClientID;
  29. // Restore any previous sign-in session before displaying main view.
  30. [[GIDSignIn sharedInstance] restorePreviousSignInWithCallback:^(GIDGoogleUser * _Nullable user,
  31. NSError * _Nullable error) {
  32. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  33. SignInViewController *masterViewController =
  34. [[SignInViewController alloc] initWithNibName:@"SignInViewController"
  35. bundle:nil];
  36. self.navigationController =
  37. [[UINavigationController alloc]
  38. initWithRootViewController:masterViewController];
  39. self.window.rootViewController = self.navigationController;
  40. [self.window makeKeyAndVisible];
  41. }];
  42. return YES;
  43. }
  44. - (BOOL)application:(UIApplication *)app
  45. openURL:(NSURL *)url
  46. options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  47. return [[GIDSignIn sharedInstance] handleURL:url];
  48. }
  49. @end