@@ -6,24 +6,42 @@ import FirebaseCore
66import FirebaseMessaging
77
88@main
9- class AppDelegate : RCTAppDelegate {
10- override func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil ) -> Bool {
11- self . moduleName = " SampleApp "
12- self . dependencyProvider = RCTAppDependencyProvider ( )
13- FirebaseApp . configure ( )
9+ class AppDelegate : UIResponder , UIApplicationDelegate {
10+ var window : UIWindow ?
11+
12+ var reactNativeDelegate : ReactNativeDelegate ?
13+ var reactNativeFactory : RCTReactNativeFactory ?
14+
15+ func application(
16+ _ application: UIApplication ,
17+ didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil
18+ ) -> Bool {
19+ let delegate = ReactNativeDelegate ( )
20+ let factory = RCTReactNativeFactory ( delegate: delegate)
21+ delegate. dependencyProvider = RCTAppDependencyProvider ( )
22+ FirebaseApp . configure ( )
23+
24+ reactNativeDelegate = delegate
25+ reactNativeFactory = factory
26+
27+ window = UIWindow ( frame: UIScreen . main. bounds)
28+
29+ factory. startReactNative (
30+ withModuleName: " SampleApp " ,
31+ in: window,
32+ launchOptions: launchOptions
33+ )
34+
35+ return true
36+ }
1437
15- // You can add your custom initial props in the dictionary below.
16- // They will be passed down to the ViewController used by React Native.
17- self . initialProps = [ : ]
18-
19- return super. application ( application, didFinishLaunchingWithOptions: launchOptions)
20- }
21-
22- override func application( _ application: UIApplication , didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) {
38+ func application( _ application: UIApplication , didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) {
2339 // Pass the device token to FCM
2440 Messaging . messaging ( ) . apnsToken = deviceToken
2541 }
42+ }
2643
44+ class ReactNativeDelegate : RCTDefaultReactNativeFactoryDelegate {
2745 override func sourceURL( for bridge: RCTBridge ) -> URL ? {
2846 self . bundleURL ( )
2947 }
0 commit comments