From af9958ad66c25d49c0548de286d8e8dc73a5ed38 Mon Sep 17 00:00:00 2001 From: Alex Bumbu Date: Fri, 30 Jul 2021 12:53:30 +0300 Subject: [PATCH] feat(ios) support for destroying & reinitializing the react native bridge --- ios/sdk/src/JitsiMeet.h | 10 ++++++++++ ios/sdk/src/JitsiMeet.m | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ios/sdk/src/JitsiMeet.h b/ios/sdk/src/JitsiMeet.h index 0b5b7f430..d9e6ddd16 100644 --- a/ios/sdk/src/JitsiMeet.h +++ b/ios/sdk/src/JitsiMeet.h @@ -59,6 +59,16 @@ #pragma mark - Utility methods +/** + * Once the react native bridge is destroyed you are responsible for reinstantiating it back. Use this method to do so. + */ +- (void)instantiateReactNativeBridge; + +/** + * Helper method to destroy the react native bridge, cleaning up resources in the process. Once the react native bridge is destroyed you are responsible for reinstantiating it back using `instantiateReactNativeBridge` method. + */ +- (void)destroyReactNativeBridge; + - (JitsiMeetConferenceOptions *_Nonnull)getInitialConferenceOptions; - (BOOL)isCrashReportingDisabled; diff --git a/ios/sdk/src/JitsiMeet.m b/ios/sdk/src/JitsiMeet.m index a7e4b8848..34b37e1d1 100644 --- a/ios/sdk/src/JitsiMeet.m +++ b/ios/sdk/src/JitsiMeet.m @@ -28,7 +28,6 @@ #import #import - @implementation JitsiMeet { RCTBridgeWrapper *_bridgeWrapper; NSDictionary *_launchOptions; @@ -50,7 +49,7 @@ - (instancetype)init { if (self = [super init]) { - // Initialize the on and only bridge for interfacing with React Native. + // Initialize the one and only bridge for interfacing with React Native. _bridgeWrapper = [[RCTBridgeWrapper alloc] init]; // Initialize the listener for handling start/stop screensharing notifications. @@ -119,6 +118,18 @@ #pragma mark - Utility methods +- (void)instantiateReactNativeBridge { + if (_bridgeWrapper != nil) { + return; + }; + + _bridgeWrapper = [[RCTBridgeWrapper alloc] init]; +} + +- (void)destroyReactNativeBridge { + _bridgeWrapper = nil; +} + - (JitsiMeetConferenceOptions *)getInitialConferenceOptions { if (_launchOptions[UIApplicationLaunchOptionsURLKey]) { NSURL *url = _launchOptions[UIApplicationLaunchOptionsURLKey];