2121#import " JitsiMeet+Private.h"
2222#import " JitsiMeetConferenceOptions+Private.h"
2323#import " JitsiMeetView+Private.h"
24- #import " RCTBridgeWrapper.h"
2524#import " ReactUtils.h"
2625#import " ScheenshareEventEmiter.h"
2726
2827#import < react-native-webrtc/WebRTCModuleOptions.h>
28+ #import < RCTReactNativeFactory.h>
29+ #import < RCTDefaultReactNativeFactoryDelegate.h>
30+ #import < ReactAppDependencyProvider/RCTAppDependencyProvider.h>
31+ #import < React/RCTBundleURLProvider.h>
2932
3033#if !defined(JITSI_MEET_SDK_LITE)
3134#import < RNGoogleSignin/RNGoogleSignin.h>
3235#import " Dropbox.h"
3336#endif
3437
38+ @interface JMReactNativeFactoryDelegate : RCTDefaultReactNativeFactoryDelegate
39+ @end
40+
41+ @implementation JMReactNativeFactoryDelegate
42+
43+ - (NSURL *)sourceURLForBridge : (RCTBridge *)bridge {
44+ return [self bundleURL ];
45+ }
46+
47+ - (NSURL *_Nullable)bundleURL {
48+ #if DEBUG
49+ return [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: @" index" ];
50+ #else
51+ return [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
52+ #endif
53+ }
54+
55+ @end
56+
3557@implementation JitsiMeet {
36- RCTBridgeWrapper *_bridgeWrapper;
3758 NSDictionary *_launchOptions;
3859 ScheenshareEventEmiter *_screenshareEventEmiter;
3960}
@@ -56,6 +77,11 @@ - (instancetype)init {
5677 // Initialize WebRTC options.
5778 self.rtcAudioDevice = nil ;
5879 self.webRtcLoggingSeverity = WebRTCLoggingSeverityNone;
80+
81+ JMReactNativeFactoryDelegate *delegate = [[JMReactNativeFactoryDelegate alloc ] init ];
82+ delegate.dependencyProvider = [[RCTAppDependencyProvider alloc ] init ];
83+ self.reactNativeFactory = [[RCTReactNativeFactory alloc ] initWithDelegate: delegate];
84+ self.dependencyProvider = delegate.dependencyProvider ;
5985
6086 // Initialize the listener for handling start/stop screensharing notifications.
6187 _screenshareEventEmiter = [[ScheenshareEventEmiter alloc ] init ];
@@ -73,9 +99,17 @@ - (instancetype)init {
7399#pragma mark - Methods that the App delegate must call
74100
75101- (BOOL )application : (UIApplication *)application
76- didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
102+ didFinishLaunchingWithOptions : (NSDictionary *)launchOptions
103+ moduleName : (NSString *)moduleName
104+ inWindow : (UIWindow *)window {
77105
78106 _launchOptions = [launchOptions copy ];
107+
108+ // Start React Native with new architecture
109+ [self .reactNativeFactory startReactNativeWithModuleName: moduleName
110+ inWindow: window
111+ initialProperties: nil
112+ launchOptions: launchOptions];
79113
80114#if !defined(JITSI_MEET_SDK_LITE)
81115 [Dropbox setAppKey ];
@@ -132,22 +166,17 @@ - (UIInterfaceOrientationMask)application:(UIApplication *)application supported
132166#pragma mark - Utility methods
133167
134168- (void )instantiateReactNativeBridge {
135- if (_bridgeWrapper != nil ) {
136- return ;
137- };
138-
139169 // Initialize WebRTC options.
140170 WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance ];
141171 options.audioDevice = _rtcAudioDevice;
142172 options.loggingSeverity = (RTCLoggingSeverity)_webRtcLoggingSeverity;
143173
144- // Initialize the one and only bridge for interfacing with React Native.
145- _bridgeWrapper = [[RCTBridgeWrapper alloc ] init ];
174+
146175}
147176
148177- (void )destroyReactNativeBridge {
149- [_bridgeWrapper invalidate ];
150- _bridgeWrapper = nil ;
178+ [self .reactNativeFactory.bridge invalidate ];
179+ self. reactNativeFactory = nil ;
151180}
152181
153182- (JitsiMeetConferenceOptions *)getInitialConferenceOptions {
@@ -260,11 +289,14 @@ - (NSDictionary *)getDefaultProps {
260289- (RCTBridge *)getReactBridge {
261290 // Initialize bridge lazily.
262291 [self instantiateReactNativeBridge ];
263- return _bridgeWrapper.bridge ;
292+
293+ // Get bridge from the new architecture factory
294+ return self.reactNativeFactory .bridge ;
264295}
265296
266297- (ExternalAPI *)getExternalAPI {
267- return [_bridgeWrapper.bridge moduleForClass: ExternalAPI.class];
298+ RCTBridge *bridge = [self getReactBridge ];
299+ return [bridge moduleForClass: ExternalAPI.class];
268300}
269301
270302@end
0 commit comments