this repo has no description
1import Expo
2import React
3import ReactAppDependencyProvider
4
5@UIApplicationMain
6public class AppDelegate: ExpoAppDelegate {
7 var window: UIWindow?
8
9 var reactNativeDelegate: ExpoReactNativeFactoryDelegate?
10 var reactNativeFactory: RCTReactNativeFactory?
11
12 public override func application(
13 _ application: UIApplication,
14 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
15 ) -> Bool {
16 let delegate = ReactNativeDelegate()
17 let factory = ExpoReactNativeFactory(delegate: delegate)
18 delegate.dependencyProvider = RCTAppDependencyProvider()
19
20 reactNativeDelegate = delegate
21 reactNativeFactory = factory
22 bindReactNativeFactory(factory)
23
24#if os(iOS) || os(tvOS)
25 window = UIWindow(frame: UIScreen.main.bounds)
26 factory.startReactNative(
27 withModuleName: "main",
28 in: window,
29 launchOptions: launchOptions)
30#endif
31
32 return super.application(application, didFinishLaunchingWithOptions: launchOptions)
33 }
34
35 // Linking API
36 public override func application(
37 _ app: UIApplication,
38 open url: URL,
39 options: [UIApplication.OpenURLOptionsKey: Any] = [:]
40 ) -> Bool {
41 return super.application(app, open: url, options: options) || RCTLinkingManager.application(app, open: url, options: options)
42 }
43
44 // Universal Links
45 public override func application(
46 _ application: UIApplication,
47 continue userActivity: NSUserActivity,
48 restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
49 ) -> Bool {
50 let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
51 return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
52 }
53}
54
55class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {
56 // Extension point for config-plugins
57
58 override func sourceURL(for bridge: RCTBridge) -> URL? {
59 // needed to return the correct URL for expo-dev-client.
60 bridge.bundleURL ?? bundleURL()
61 }
62
63 override func bundleURL() -> URL? {
64#if DEBUG
65 return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: ".expo/.virtual-metro-entry")
66#else
67 return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
68#endif
69 }
70}