diff --git a/android/build.gradle b/android/build.gradle index 269e629..da80075 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -14,7 +14,7 @@ if (isNewArchitectureEnabled()) { } android { - compileSdkVersion safeExtGet('compileSdkVersion', 31) + compileSdkVersion safeExtGet('compileSdkVersion', 34) sourceSets { main { @@ -29,7 +29,7 @@ android { defaultConfig { minSdkVersion safeExtGet('minSdkVersion', 21) - targetSdkVersion safeExtGet('targetSdkVersion', 31) + targetSdkVersion safeExtGet('targetSdkVersion', 34) versionCode 1 versionName "1.0" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() @@ -48,7 +48,7 @@ repositories { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" - implementation "com.voximplant:voximplant-sdk:2.39.0" + implementation "com.voximplant:voximplant-sdk:2.40.1" implementation "androidx.annotation:annotation:1.5.0" } diff --git a/android/src/main/java/com/voximplant/reactnative/Utils.java b/android/src/main/java/com/voximplant/reactnative/Utils.java index cc8ef37..53271d7 100644 --- a/android/src/main/java/com/voximplant/reactnative/Utils.java +++ b/android/src/main/java/com/voximplant/reactnative/Utils.java @@ -328,6 +328,9 @@ static WritableMap createObjectWritableMap(Map map) { } static Node convertStringToNode(String node) { + if (node == null) { + return null; + } switch (node) { case "node1": return Node.NODE_1; @@ -350,7 +353,7 @@ static Node convertStringToNode(String node) { case "node10": return Node.NODE_10; default: - return Node.NODE_1; + return null; } } diff --git a/android/src/main/java/com/voximplant/reactnative/VIClientModule.java b/android/src/main/java/com/voximplant/reactnative/VIClientModule.java index af44bc7..b83d701 100644 --- a/android/src/main/java/com/voximplant/reactnative/VIClientModule.java +++ b/android/src/main/java/com/voximplant/reactnative/VIClientModule.java @@ -103,7 +103,7 @@ public String getName() { //region React methods @ReactMethod public void init(ReadableMap settings) { - Voximplant.subVersion = "react-1.41.0"; + Voximplant.subVersion = "react-1.42.0"; ClientConfig config = Utils.convertClientConfigFromMap(settings); try { mClient = Voximplant.getClientInstance(Executors.newSingleThreadExecutor(), mReactContext, config); @@ -135,13 +135,13 @@ public void connect(boolean connectivityCheck, ReadableArray servers, String nod serversList = null; } try { - if (node != null) { - Node connectionNode = Utils.convertStringToNode(node); + Node connectionNode = Utils.convertStringToNode(node); + if (connectionNode != null) { mClient.connect(connectionNode, connectivityCheck, serversList); + callback.invoke(true); } else { - mClient.connect(connectivityCheck, serversList); + onConnectionFailed("Invalid ConnectionNode"); } - callback.invoke(true); } catch (IllegalStateException e) { callback.invoke(false); } diff --git a/android/src/main/java/com/voximplant/reactnative/VideoViewImpl.java b/android/src/main/java/com/voximplant/reactnative/VideoViewImpl.java index 73a2ebf..30205a6 100644 --- a/android/src/main/java/com/voximplant/reactnative/VideoViewImpl.java +++ b/android/src/main/java/com/voximplant/reactnative/VideoViewImpl.java @@ -14,8 +14,8 @@ import com.voximplant.sdk.call.IVideoStream; import com.voximplant.sdk.call.RenderScaleType; -import org.webrtc.RendererCommon; -import org.webrtc.SurfaceViewRenderer; +import com.voximplant.webrtc.RendererCommon; +import com.voximplant.webrtc.SurfaceViewRenderer; import static com.voximplant.reactnative.Constants.SCALE_TYPE_FILL; import static com.voximplant.reactnative.Constants.SCALE_TYPE_FIT; diff --git a/ios/RNVIClientModule.m b/ios/RNVIClientModule.m index 995b413..f6745d1 100644 --- a/ios/RNVIClientModule.m +++ b/ios/RNVIClientModule.m @@ -80,7 +80,7 @@ - (void)stopObserving { RCT_EXPORT_METHOD(initWithOptions:(NSDictionary *)options) { VILogLevel logLevel = [RNVIUtils convertLogLevelFromString:[options objectForKey:@"logLevel"]]; [VIClient setLogLevel:logLevel]; - [VIClient setVersionExtension:@"react-1.41.0"]; + [VIClient setVersionExtension:@"react-1.42.0"]; NSString *bundleId = [options objectForKey:@"bundleId"]; if (bundleId) { _client = [RNVICallManager getClientWithBundleId:bundleId]; @@ -104,12 +104,16 @@ - (void)stopObserving { RCT_EXPORT_METHOD(connect:(BOOL)connectivityCheck gateways:(NSArray *)gateways node:(nullable NSString *)node callback:(RCTResponseSenderBlock)callback) { if (_client) { BOOL isValidState = NO; - if (node) { - VIConnectionNode connectionNode = [RNVIUtils convertConnectionNodeFromString:node]; - isValidState = [_client connectTo:connectionNode connectivityCheck:connectivityCheck gateways:gateways]; - } else { - isValidState = [_client connectWithConnectivityCheck:connectivityCheck gateways:gateways]; + BOOL isNodeValid = [RNVIUtils validateConnectionNodeString:node]; + if (!isNodeValid) { + [self sendEventWithName:kEventConnectionFailed body:@{ + kEventParamName : kEventNameConnectionFailed, + kEventParamMessage : @"Invalid ConnectionNode", + }]; + return; } + VIConnectionNode connectionNode = [RNVIUtils convertConnectionNodeFromString:node]; + isValidState = [_client connectTo:connectionNode connectivityCheck:connectivityCheck gateways:gateways]; callback(@[[NSNumber numberWithBool:isValidState]]); } } diff --git a/ios/RNVIUtils.h b/ios/RNVIUtils.h index cbc4f5c..8846ef4 100644 --- a/ios/RNVIUtils.h +++ b/ios/RNVIUtils.h @@ -26,6 +26,7 @@ + (NSString *)convertQualityIssueLevelToString:(VIQualityIssueLevel)level; + (NSString *)convertQualityIssueTypeToString:(VIQualityIssueType)type; + (VIConnectionNode)convertConnectionNodeFromString:(NSString *)node; ++ (BOOL)validateConnectionNodeString:(NSString *)node; @end diff --git a/ios/RNVIUtils.m b/ios/RNVIUtils.m index 4841d2c..78bd542 100644 --- a/ios/RNVIUtils.m +++ b/ios/RNVIUtils.m @@ -352,6 +352,19 @@ + (VIConnectionNode)convertConnectionNodeFromString:(NSString *)node { return VIConnectionNodeNode1; } ++ (BOOL)validateConnectionNodeString:(NSString *)node { + return [node isEqualToString:@"node1"] || + [node isEqualToString:@"node2"] || + [node isEqualToString:@"node3"] || + [node isEqualToString:@"node4"] || + [node isEqualToString:@"node5"] || + [node isEqualToString:@"node6"] || + [node isEqualToString:@"node7"] || + [node isEqualToString:@"node8"] || + [node isEqualToString:@"node9"] || + [node isEqualToString:@"node10"]; +} + @end @implementation NSNumber (FromTimeInterval) diff --git a/react-native-voximplant.podspec b/react-native-voximplant.podspec index a0bdeb4..d22d14c 100644 --- a/react-native-voximplant.podspec +++ b/react-native-voximplant.podspec @@ -5,13 +5,13 @@ Pod::Spec.new do |s| s.name = 'react-native-voximplant' s.author = { 'Zingaya Inc.' => 'info@voximplant.com' } s.source_files = 'ios/*' - s.platform = :ios, '11.0' + s.platform = :ios, '12.0' s.license = 'MIT' s.homepage = 'https://github.com/voximplant/react-native-voximplant' s.source = {:path => './ios/'} s.summary = 'RN voximplant' - s.version = '1.41.0' - s.dependency 'VoxImplantSDK', '2.52.0' + s.version = '1.42.0' + s.dependency 'VoxImplantSDK', '2.53.0' if fabric_enabled s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" s.pod_target_xcconfig = { diff --git a/src/client/Client.js b/src/client/Client.js index e65d667..263ad6c 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -156,12 +156,17 @@ export default class Client { */ connect(options) { return new Promise((resolve, reject) => { - if (!options) options = {}; + if (!options) { + console.error('ConnectOptions and ConnectionNode are required'); + reject({'name': ClientEvents.ConnectionFailed, 'message': 'ConnectOptions and ConnectionNode are required'}); + return; + } if (options.connectivityCheck === undefined) options.connectivityCheck = false; if (options.servers === undefined) options.servers = []; if (!options.node) { - console.warn('Node parameter is missing. It will be required in the next release.'); - options.node = null; + console.error('ConnectionNode is required'); + reject({'name': ClientEvents.ConnectionFailed, 'message': 'ConnectionNode is required'}); + return; } let connected = (event) => { resolve(event);