1#import "AppDelegate.h" 2 3#import <React/RCTBridge.h> 4#import <React/RCTBundleURLProvider.h> 5#import <React/RCTRootView.h> 6#import <React/RCTLinkingManager.h> 7 8@import ExpoModulesCore; 9@import EXDevMenu; 10 11#import <EXDevLauncher/EXDevLauncherController.h> 12 13@interface DevMenuDetoxTestInterceptor : NSObject<DevMenuTestInterceptor> 14 15@end 16 17@implementation DevMenuDetoxTestInterceptor 18 19- (BOOL)isOnboardingFinishedKey 20{ 21 return YES; 22} 23 24- (BOOL)shouldShowAtLaunch 25{ 26 return NO; 27} 28 29@end 30 31@interface AppDelegate () <RCTBridgeDelegate> 32 33@property (nonatomic, strong) NSDictionary *launchOptions; 34 35@end 36 37@implementation AppDelegate 38 39- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 40{ 41 [DevMenuTestInterceptorManager setTestInterceptor:[DevMenuDetoxTestInterceptor new]]; 42 43 self.launchOptions = launchOptions; 44 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 45 46 EXDevLauncherController *controller = [EXDevLauncherController sharedInstance]; 47 [controller startWithWindow:self.window delegate:(id<EXDevLauncherControllerDelegate>)self launchOptions:launchOptions]; 48 49 [super application:application didFinishLaunchingWithOptions:launchOptions]; 50 51 return YES; 52} 53 54- (RCTBridge *)initializeReactNativeApp 55{ 56 NSDictionary *launchOptions = [EXDevLauncherController.sharedInstance getLaunchOptions]; 57 58 RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 59 RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; 60 rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 61 62 UIViewController *rootViewController = [UIViewController new]; 63 rootViewController.view = rootView; 64 self.window.rootViewController = rootViewController; 65 [self.window makeKeyAndVisible]; 66 67 return bridge; 68 } 69 70- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { 71 return [[EXDevLauncherController sharedInstance] sourceUrl]; 72} 73 74// Linking API 75- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { 76 if ([EXDevLauncherController.sharedInstance onDeepLink:url options:options]) { 77 return true; 78 } 79 80 return [RCTLinkingManager application:application openURL:url options:options]; 81} 82 83// Universal Links 84- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler { 85 return [RCTLinkingManager application:application 86 continueUserActivity:userActivity 87 restorationHandler:restorationHandler]; 88} 89 90@end 91 92@implementation AppDelegate (EXDevLauncherControllerDelegate) 93 94- (void)devLauncherController:(EXDevLauncherController *)developmentClientController 95 didStartWithSuccess:(BOOL)success 96{ 97 developmentClientController.appBridge = [self initializeReactNativeApp]; 98} 99 100@end