ApplicationDelegate.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright 2017 Google
  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 "ApplicationDelegate.h"
  17. #import "FIRApp.h"
  18. #import "FirebaseAuth.h"
  19. #import "AuthProviders.h"
  20. #import "MainViewController.h"
  21. #if INTERNAL_GOOGLE3_BUILD
  22. #import "googlemac/iPhone/Identity/Firebear/InternalUtils/FIRSessionFetcherLogging.h"
  23. #import "third_party/firebase/ios/Source/FirebaseCore/Library/Private/FIRLogger.h"
  24. #endif
  25. /** @var gOpenURLDelegate
  26. @brief The delegate to for application:openURL:... method.
  27. */
  28. static __weak id<OpenURLDelegate> gOpenURLDelegate;
  29. @implementation ApplicationDelegate
  30. + (void)setOpenURLDelegate:(nullable id<OpenURLDelegate>)openURLDelegate {
  31. gOpenURLDelegate = openURLDelegate;
  32. }
  33. - (BOOL)application:(UIApplication *)application
  34. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  35. #if INTERNAL_GOOGLE3_BUILD
  36. [FIRSessionFetcherLogging setEnabled:YES];
  37. FIRSetLoggerLevel(FIRLoggerLevelInfo);
  38. #endif
  39. // Configure the default Firebase application:
  40. [FIRApp configure];
  41. // Load and present the UI:
  42. UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  43. window.rootViewController =
  44. [[MainViewController alloc] initWithNibName:NSStringFromClass([MainViewController class])
  45. bundle:nil];
  46. self.window = window;
  47. [self.window makeKeyAndVisible];
  48. return YES;
  49. }
  50. - (BOOL)application:(nonnull UIApplication *)application
  51. openURL:(nonnull NSURL *)url
  52. options:(nonnull NSDictionary<NSString *, id> *)options {
  53. return [self application:application
  54. openURL:url
  55. sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
  56. annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  57. }
  58. - (BOOL)application:(UIApplication *)application
  59. openURL:(NSURL *)url
  60. sourceApplication:(NSString *)sourceApplication
  61. annotation:(id)annotation {
  62. if ([gOpenURLDelegate handleOpenURL:url sourceApplication:sourceApplication]) {
  63. return YES;
  64. }
  65. return NO;
  66. }
  67. @end