1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 import Foundation 4 5 @UIApplicationMain 6 class AppDelegate: UMAppDelegateWrapper { 7 var rootViewController: EXRootViewController? 8 9 override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 10 if (application.applicationState != UIApplication.State.background) { 11 // App launched in foreground 12 setUpUserInterfaceForApplication(application, withLaunchOptions: launchOptions) 13 } 14 15 super.application(application, didFinishLaunchingWithOptions: launchOptions) 16 17 // SplashScreen module registers SplashScreenView automatically for window.rootViewController (EXRootViewController), 18 // and we want it to register for EXViewController (that is found in rootViewContrller view hierarchy), 19 // so we need to hide it for window.rootViewController 20 let splashScreenService: EXSplashScreenService = UMModuleRegistryProvider.getSingletonModule(for: EXSplashScreenService.self) as! EXSplashScreenService 21 if let rootViewController = window?.rootViewController { 22 splashScreenService.hideSplashScreen(for: rootViewController, 23 successCallback: { (success) in /* empty */ }, 24 failureCallback: { (message) in /* empty */ }) 25 } 26 return true 27 } 28 29 override func applicationWillEnterForeground(_ application: UIApplication) { 30 setUpUserInterfaceForApplication(application, withLaunchOptions: nil) 31 super.applicationWillEnterForeground(application) 32 } 33 34 private func setUpUserInterfaceForApplication(_ application: UIApplication, withLaunchOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) { 35 if (self.window != nil) { 36 return 37 } 38 39 ExpoKit.sharedInstance().registerRootViewControllerClass(EXRootViewController.self) 40 ExpoKit.sharedInstance().prepare(launchOptions: launchOptions) 41 42 window = UIWindow(frame: UIScreen.main.bounds) 43 window!.backgroundColor = UIColor.white 44 rootViewController = (ExpoKit.sharedInstance().rootViewController() as! EXRootViewController) 45 window!.rootViewController = rootViewController 46 47 window!.makeKeyAndVisible() 48 } 49 } 50