Advertisement
Guest User

Untitled

a guest
Apr 29th, 2020
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7.  
  8. @import Firebase;
  9. #import "AppDelegate.h"
  10.  
  11. #import <React/RCTBundleURLProvider.h>
  12. #import <React/RCTRootView.h>
  13.  
  14. #import <EXSplashScreen/EXSplashScreenService.h>
  15. #import <UMCore/UMModuleRegistryProvider.h>
  16. #import <UMCore/UMModuleRegistry.h>
  17. #import <UMReactNativeAdapter/UMNativeModulesProxy.h>
  18. #import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
  19.  
  20. @interface AppDelegate ()
  21.  
  22. @property (nonatomic, strong) NSDictionary *launchOptions;
  23.  
  24. @end
  25.  
  26. @implementation AppDelegate
  27.  
  28. @synthesize window = _window;
  29.  
  30. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  31. {
  32. [FIRApp configure];
  33. self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
  34. self.launchOptions = launchOptions;
  35.  
  36. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  37. #ifdef DEBUG
  38. [self initializeReactNativeApp];
  39. #else
  40. EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance];
  41. controller.delegate = self;
  42. [controller startAndShowLaunchScreen:self.window];
  43. #endif
  44.  
  45. [super application:application didFinishLaunchingWithOptions:launchOptions];
  46.  
  47. return YES;
  48. }
  49.  
  50. - (RCTBridge *)initializeReactNativeApp
  51. {
  52. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
  53. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
  54. rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  55.  
  56. UIViewController *rootViewController = [UIViewController new];
  57. rootViewController.view = rootView;
  58. self.window.rootViewController = rootViewController;
  59. [self.window makeKeyAndVisible];
  60.  
  61. EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]];
  62. [splashScreenService showSplashScreenFor:rootViewController];
  63.  
  64. return bridge;
  65. }
  66.  
  67. - (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
  68. {
  69. NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
  70. // You can inject any extra modules that you would like here, more information at:
  71. // https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
  72. return extraModules;
  73. }
  74.  
  75. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
  76. #ifdef DEBUG
  77. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  78. #else
  79. return [[EXUpdatesAppController sharedInstance] launchAssetUrl];
  80. #endif
  81. }
  82.  
  83. - (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success
  84. {
  85. appController.bridge = [self initializeReactNativeApp];
  86. }
  87.  
  88. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement