77
88#import " SceneDelegate.h"
99
10- #import < UserNotifications/UserNotifications.h>
11-
1210#import < React/RCTBundleURLProvider.h>
1311#import < React/RCTDefines.h>
14- #import < React/RCTLinkingManager.h>
1512#import < ReactCommon/RCTSampleTurboModule.h>
1613#import < ReactCommon/RCTTurboModuleManager.h>
1714
18- #import < React/RCTPushNotificationManager.h>
19-
2015#import < NativeCxxModuleExample/NativeCxxModuleExample.h>
2116#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
2217#import < RNTMyNativeViewComponentView.h>
2924#define USE_OSS_CODEGEN 0
3025#endif
3126
32- @interface SceneDelegate ()
33- @end
27+ #if RCT_DEV_MENU
28+ #import < React/RCTDevMenu.h>
29+ #endif
30+
31+ static NSString *kBundlePath = @" js/RNTesterApp.ios" ;
3432
3533@implementation SceneDelegate
3634
@@ -49,54 +47,54 @@ - (void)scene:(UIScene *)scene
4947 willConnectToSession : (UISceneSession *)session
5048 options : (UISceneConnectionOptions *)connectionOptions
5149{
52- if (![scene isKindOfClass: [UIWindowScene class ]])
53- return ;
54-
55- UIWindowScene *windowScene = (UIWindowScene *)scene;
56- self.window = [[UIWindow alloc ] initWithWindowScene: windowScene];
57-
58- ReactNativeDelegate *delegate = [[ReactNativeDelegate alloc ] init ];
59- RCTReactNativeFactory *factory = [[RCTReactNativeFactory alloc ] initWithDelegate: delegate];
60-
50+ self.moduleName = @" RNTesterApp" ;
51+ self.initialProps = [self prepareInitialProps ];
6152#if USE_OSS_CODEGEN
62- delegate .dependencyProvider = [[RCTAppDependencyProvider alloc ] init ];
53+ self .dependencyProvider = [[RCTAppDependencyProvider alloc ] init ];
6354#endif
6455
65- self.reactNativeDelegate = delegate;
66- self.reactNativeFactory = factory;
56+ [super scene: scene willConnectToSession: session options: connectionOptions];
6757
68- [factory startReactNativeWithModuleName: @" RNTesterApp"
69- inWindow: self .window
70- initialProperties: [self prepareInitialProps ]
71- connectionOptions: connectionOptions];
58+ #if RCT_DEV_MENU
59+ RCTDevMenuConfiguration *devMenuConfiguration = [[RCTDevMenuConfiguration alloc ] initWithDevMenuEnabled: true
60+ shakeGestureEnabled: true
61+ keyboardShortcutsEnabled: true ];
62+ [self .reactNativeFactory setDevMenuConfiguration: devMenuConfiguration];
63+ #endif
7264}
7365
74- - (void ) scene : (UIScene *)scene openURLContexts : ( NSSet <UIOpenURLContext *> *) URLContexts
66+ - (NSURL *)sourceURLForBridge : (RCTBridge *) bridge
7567{
76- [RCTLinkingManager scene: scene openURLContexts: URLContexts ];
68+ return [ self bundleURL ];
7769}
7870
79- - (void ) scene : (UIScene *)scene continueUserActivity : ( NSUserActivity *) userActivity
71+ - (NSURL *)bundleURL
8072{
81- [RCTLinkingManager scene: scene continueUserActivity: userActivity ];
73+ return [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: kBundlePath ];
8274}
8375
84- @end
85-
86- @implementation ReactNativeDelegate
87-
88- - (NSURL *)sourceURLForBridge : (RCTBridge *)bridge
76+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule : (const std::string &)name
77+ jsInvoker : (std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
8978{
90- return [self bundleURL ];
79+ if (name == facebook::react::NativeCxxModuleExample::kModuleName ) {
80+ return std::make_shared<facebook::react::NativeCxxModuleExample>(jsInvoker);
81+ }
82+
83+ return [super getTurboModule: name jsInvoker: jsInvoker];
9184}
9285
93- - (NSURL *)bundleURL
86+ #ifndef RN_DISABLE_OSS_PLUGIN_HEADER
87+ - (nonnull NSDictionary <NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
9488{
95- #if DEBUG
96- return [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: @" js/RNTesterApp.ios" ];
97- #else
98- return [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
99- #endif
89+ NSMutableDictionary *dict = [super thirdPartyFabricComponents ].mutableCopy ;
90+ if (!dict[@" RNTMyNativeView" ]) {
91+ dict[@" RNTMyNativeView" ] = NSClassFromString (@" RNTMyNativeViewComponentView" );
92+ }
93+ if (!dict[@" SampleNativeComponent" ]) {
94+ dict[@" SampleNativeComponent" ] = NSClassFromString (@" RCTSampleNativeComponentComponentView" );
95+ }
96+ return dict;
10097}
98+ #endif
10199
102100@end
0 commit comments