ApplicationDelegate.m 2.4 KB

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