summaryrefslogtreecommitdiff
path: root/ios/client/AppDelegate.swift
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-16 14:54:44 +0700
committerpolwex <polwex@sortug.com>2025-07-16 14:54:44 +0700
commitaadfe206f3233032d8742a17c1f21d4750946a41 (patch)
treea63a95381ff99af1226ef096ce94cc32d8153ca5 /ios/client/AppDelegate.swift
parent1c81a70b0349a7f7577d0124b4b67ab5ea01e68d (diff)
aaaarggh!!!
Diffstat (limited to 'ios/client/AppDelegate.swift')
-rw-r--r--ios/client/AppDelegate.swift70
1 files changed, 70 insertions, 0 deletions
diff --git a/ios/client/AppDelegate.swift b/ios/client/AppDelegate.swift
new file mode 100644
index 0000000..a7887e1
--- /dev/null
+++ b/ios/client/AppDelegate.swift
@@ -0,0 +1,70 @@
+import Expo
+import React
+import ReactAppDependencyProvider
+
+@UIApplicationMain
+public class AppDelegate: ExpoAppDelegate {
+ var window: UIWindow?
+
+ var reactNativeDelegate: ExpoReactNativeFactoryDelegate?
+ var reactNativeFactory: RCTReactNativeFactory?
+
+ public override func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
+ ) -> Bool {
+ let delegate = ReactNativeDelegate()
+ let factory = ExpoReactNativeFactory(delegate: delegate)
+ delegate.dependencyProvider = RCTAppDependencyProvider()
+
+ reactNativeDelegate = delegate
+ reactNativeFactory = factory
+ bindReactNativeFactory(factory)
+
+#if os(iOS) || os(tvOS)
+ window = UIWindow(frame: UIScreen.main.bounds)
+ factory.startReactNative(
+ withModuleName: "main",
+ in: window,
+ launchOptions: launchOptions)
+#endif
+
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
+ }
+
+ // Linking API
+ public override func application(
+ _ app: UIApplication,
+ open url: URL,
+ options: [UIApplication.OpenURLOptionsKey: Any] = [:]
+ ) -> Bool {
+ return super.application(app, open: url, options: options) || RCTLinkingManager.application(app, open: url, options: options)
+ }
+
+ // Universal Links
+ public override func application(
+ _ application: UIApplication,
+ continue userActivity: NSUserActivity,
+ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
+ ) -> Bool {
+ let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
+ return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
+ }
+}
+
+class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {
+ // Extension point for config-plugins
+
+ override func sourceURL(for bridge: RCTBridge) -> URL? {
+ // needed to return the correct URL for expo-dev-client.
+ bridge.bundleURL ?? bundleURL()
+ }
+
+ override func bundleURL() -> URL? {
+#if DEBUG
+ return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: ".expo/.virtual-metro-entry")
+#else
+ return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
+#endif
+ }
+}