Skip to content

Commit 1b33672

Browse files
committed
chore(ios): use bridge from react native factory
1 parent c07129d commit 1b33672

File tree

3 files changed

+68
-17
lines changed

3 files changed

+68
-17
lines changed

ios/app/src/AppDelegate.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2727
builder.setFeatureFlag("ios.recording.enabled", withBoolean: true)
2828
}
2929

30-
jitsiMeet.application(application, didFinishLaunchingWithOptions: launchOptions ?? [:])
30+
let vc = ViewController()
31+
self.window?.rootViewController = vc
32+
33+
jitsiMeet.application(application,
34+
didFinishLaunchingWithOptions: launchOptions ?? [:],
35+
moduleName: "App",
36+
in: self.window!)
3137

3238
if self.appContainsRealServiceInfoPlist() {
3339
print("Enabling Firebase")
3440
FirebaseApp.configure()
3541
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(!jitsiMeet.isCrashReportingDisabled())
3642
}
3743

38-
let vc = ViewController()
39-
self.window?.rootViewController = vc
4044
jitsiMeet.showSplashScreen()
4145

4246
self.window?.makeKeyAndVisible()

ios/sdk/src/JitsiMeet.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
#import <JitsiMeetSDK/JitsiMeetConferenceOptions.h>
2121

22+
@class RCTReactNativeFactory;
23+
@protocol RCTDependencyProvider;
24+
2225
// Matches RTCLoggingSeverity from RTCLogging.h
2326
typedef NS_ENUM(NSInteger, WebRTCLoggingSeverity) {
2427
WebRTCLoggingSeverityVerbose,
@@ -64,14 +67,26 @@ typedef NS_ENUM(NSInteger, WebRTCLoggingSeverity) {
6467
*/
6568
@property (nonatomic, assign) WebRTCLoggingSeverity webRtcLoggingSeverity;
6669

70+
/**
71+
* React Native factory instance for managing React Native lifecycle.
72+
*/
73+
@property (nonatomic, strong, nullable) RCTReactNativeFactory *reactNativeFactory;
74+
75+
/**
76+
* Dependency provider for React Native modules and components.
77+
*/
78+
@property (nonatomic, strong, nullable) id<RCTDependencyProvider> dependencyProvider;
79+
6780
#pragma mark - This class is a singleton
6881

6982
+ (instancetype _Nonnull)sharedInstance;
7083

7184
#pragma mark - Methods that the App delegate must call
7285

7386
- (BOOL)application:(UIApplication *_Nonnull)application
74-
didFinishLaunchingWithOptions:(NSDictionary *_Nonnull)launchOptions;
87+
didFinishLaunchingWithOptions:(NSDictionary *_Nonnull)launchOptions
88+
moduleName:(NSString *_Nonnull)moduleName
89+
inWindow:(UIWindow *_Nonnull)window;
7590

7691
- (BOOL)application:(UIApplication *_Nonnull)application
7792
continueUserActivity:(NSUserActivity *_Nonnull)userActivity

ios/sdk/src/JitsiMeet.m

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,40 @@
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

Comments
 (0)