mirror of
https://github.com/videojs/video.js.git
synced 2026-11-20 06:29:27 +01:00
Co-authored-by: Emily Dixon <edixon@mux.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Emily Dixon <puterbaugh0@gmail.com>
62 lines
1.7 KiB
Swift
62 lines
1.7 KiB
Swift
import UIKit
|
|
import React
|
|
import React_RCTAppDelegate
|
|
import ReactAppDependencyProvider
|
|
|
|
@main
|
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
var reactNativeDelegate: ReactNativeDelegate?
|
|
var reactNativeFactory: RCTReactNativeFactory?
|
|
|
|
func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
) -> Bool {
|
|
let delegate = ReactNativeDelegate()
|
|
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
|
|
reactNativeDelegate = delegate
|
|
reactNativeFactory = factory
|
|
|
|
return true
|
|
}
|
|
}
|
|
|
|
// The iOS 27 SDK refuses to launch apps without the UIScene life cycle, so the window comes from the scene.
|
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
var window: UIWindow?
|
|
|
|
func scene(
|
|
_ scene: UIScene,
|
|
willConnectTo session: UISceneSession,
|
|
options connectionOptions: UIScene.ConnectionOptions
|
|
) {
|
|
guard let windowScene = scene as? UIWindowScene,
|
|
let appDelegate = UIApplication.shared.delegate as? AppDelegate
|
|
else { return }
|
|
|
|
window = UIWindow(windowScene: windowScene)
|
|
|
|
appDelegate.reactNativeFactory?.startReactNative(
|
|
withModuleName: "VideojsExample",
|
|
in: window,
|
|
launchOptions: nil
|
|
)
|
|
}
|
|
}
|
|
|
|
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
self.bundleURL()
|
|
}
|
|
|
|
override func bundleURL() -> URL? {
|
|
#if DEBUG
|
|
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
#else
|
|
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
#endif
|
|
}
|
|
}
|