xref: /expo/ios/Client/AppDelegate.swift (revision 765b47da)
1 // Copyright 2015-present 650 Industries. All rights reserved.
2 
3 import Foundation
4 import ExpoModulesCore
5 
6 @UIApplicationMain
7 class AppDelegate: ExpoAppDelegate {
8   var rootViewController: EXRootViewController?
9 
applicationnull10   override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
11     if application.applicationState != UIApplication.State.background {
12       // App launched in foreground
13       setUpUserInterfaceForApplication(application, withLaunchOptions: launchOptions)
14     }
15 
16     super.application(application, didFinishLaunchingWithOptions: launchOptions)
17 
18     return true
19   }
20 
applicationWillEnterForegroundnull21   override func applicationWillEnterForeground(_ application: UIApplication) {
22     setUpUserInterfaceForApplication(application, withLaunchOptions: nil)
23     super.applicationWillEnterForeground(application)
24   }
25 
setUpUserInterfaceForApplicationnull26   private func setUpUserInterfaceForApplication(_ application: UIApplication, withLaunchOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
27     if self.window != nil {
28       return
29     }
30 
31     ExpoKit.sharedInstance().registerRootViewControllerClass(EXRootViewController.self)
32     ExpoKit.sharedInstance().prepare(launchOptions: launchOptions)
33 
34     window = UIWindow(frame: UIScreen.main.bounds)
35     window!.backgroundColor = UIColor.white
36     rootViewController = (ExpoKit.sharedInstance().rootViewController() as! EXRootViewController)
37     window!.rootViewController = rootViewController
38 
39     window!.makeKeyAndVisible()
40   }
41 }
42