Something went wrong. Try again.
Prevent the phone screen from going to sleep.
Something went wrong. Try again.
1.2 kB · 48 lines
Swift
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import UIKitimport Reactimport React_RCTAppDelegateimport ReactAppDependencyProvider
@mainclass AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow?
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
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative( withModuleName: "KeepAwakeExample", in: window, launchOptions: launchOptions )
return true }}
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 }}