|
9 | 9 | #import <UserNotifications/UserNotifications.h>
|
10 | 10 | #import <RNCPushNotificationIOS.h>
|
11 | 11 |
|
12 |
| -#ifdef FB_SONARKIT_ENABLED |
13 |
| - #import <FlipperKit/FlipperClient.h> |
14 |
| - #import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h> |
15 |
| - #import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h> |
16 |
| - #import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h> |
17 |
| - #import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h> |
18 |
| - #import <FlipperKitReactPlugin/FlipperKitReactPlugin.h> |
19 |
| - |
20 |
| - static void InitializeFlipper(UIApplication *application) { |
21 |
| - FlipperClient *client = [FlipperClient sharedClient]; |
22 |
| - SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; |
23 |
| - [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; |
24 |
| - [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; |
25 |
| - [client addPlugin:[FlipperKitReactPlugin new]]; |
26 |
| - [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; |
27 |
| - [client start]; |
28 |
| - } |
| 12 | +#import <React/RCTAppSetupUtils.h> |
| 13 | + |
| 14 | +#if RCT_NEW_ARCH_ENABLED |
| 15 | +#import <React/CoreModulesPlugins.h> |
| 16 | +#import <React/RCTCxxBridgeDelegate.h> |
| 17 | +#import <ReactCommon/RCTTurboModuleManager.h> |
| 18 | +#import <React/RCTFabricSurfaceHostingProxyRootView.h> |
| 19 | +#import <React/RCTSurfacePresenter.h> |
| 20 | +#import <React/RCTSurfacePresenterBridgeAdapter.h> |
| 21 | + |
| 22 | +#import <react/config/ReactNativeConfig.h> |
| 23 | + |
| 24 | +@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { |
| 25 | + RCTTurboModuleManager *_turboModuleManager; |
| 26 | + RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; |
| 27 | + std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig; |
| 28 | + facebook::react::ContextContainer::Shared _contextContainer; |
| 29 | +} |
| 30 | +@end |
29 | 31 | #endif
|
30 | 32 |
|
31 | 33 | @implementation AppDelegate
|
32 | 34 |
|
33 | 35 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
34 | 36 | {
|
35 |
| - #ifdef FB_SONARKIT_ENABLED |
36 |
| - InitializeFlipper(application); |
37 |
| - #endif |
| 37 | + RCTAppSetupPrepareApp(application); |
38 | 38 |
|
39 | 39 | RCTSetLogThreshold(RCTLogLevelError);
|
40 | 40 |
|
41 | 41 | RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
|
42 |
| - RCTRootView *rootView = [self.reactDelegate createRootViewWithBridge:bridge |
43 |
| - moduleName:@"ZulipMobile" |
44 |
| - initialProperties:nil]; |
| 42 | + |
| 43 | +#if RCT_NEW_ARCH_ENABLED |
| 44 | + _contextContainer = std::make_shared<facebook::react::ContextContainer const>(); |
| 45 | + _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>(); |
| 46 | + _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); |
| 47 | + _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; |
| 48 | + bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; |
| 49 | +#endif |
| 50 | + |
| 51 | + RCTRootView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"ZulipMobile" initialProperties:nil]; |
45 | 52 |
|
46 | 53 | UIView* loadingView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
47 | 54 | loadingView.backgroundColor = [UIColor colorNamed:@"Brand"];
|
@@ -140,4 +147,42 @@ -(void)userNotificationCenter:(UNUserNotificationCenter *)center
|
140 | 147 | );
|
141 | 148 | }
|
142 | 149 |
|
| 150 | +#if RCT_NEW_ARCH_ENABLED |
| 151 | + |
| 152 | +#pragma mark - RCTCxxBridgeDelegate |
| 153 | + |
| 154 | +- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge |
| 155 | +{ |
| 156 | + _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge |
| 157 | + delegate:self |
| 158 | + jsInvoker:bridge.jsCallInvoker]; |
| 159 | + return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); |
| 160 | +} |
| 161 | + |
| 162 | +#pragma mark RCTTurboModuleManagerDelegate |
| 163 | + |
| 164 | +- (Class)getModuleClassFromName:(const char *)name |
| 165 | +{ |
| 166 | + return RCTCoreModulesClassProvider(name); |
| 167 | +} |
| 168 | + |
| 169 | +- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name |
| 170 | + jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker |
| 171 | +{ |
| 172 | + return nullptr; |
| 173 | +} |
| 174 | + |
| 175 | +- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name |
| 176 | + initParams:(const facebook::react::ObjCTurboModule::InitParams &)params |
| 177 | +{ |
| 178 | + return nullptr; |
| 179 | +} |
| 180 | + |
| 181 | +- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass |
| 182 | +{ |
| 183 | + return RCTAppSetupDefaultModuleFromClass(moduleClass); |
| 184 | +} |
| 185 | + |
| 186 | +#endif |
| 187 | + |
143 | 188 | @end
|
0 commit comments