Skip to content

Commit

Permalink
Update native modules to use Voximplant Android SDK 2.40.1 and Voximp…
Browse files Browse the repository at this point in the history
…lant iOS SDK 2.53.0
  • Loading branch information
YuliaGrigorieva committed Jun 13, 2024
1 parent 3bec4b2 commit 04542cc
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 23 deletions.
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (isNewArchitectureEnabled()) {
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 31)
compileSdkVersion safeExtGet('compileSdkVersion', 34)

sourceSets {
main {
Expand All @@ -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()
Expand All @@ -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"
}

Expand Down
5 changes: 4 additions & 1 deletion android/src/main/java/com/voximplant/reactnative/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ static WritableMap createObjectWritableMap(Map<String, Object> map) {
}

static Node convertStringToNode(String node) {
if (node == null) {
return null;
}
switch (node) {
case "node1":
return Node.NODE_1;
Expand All @@ -350,7 +353,7 @@ static Node convertStringToNode(String node) {
case "node10":
return Node.NODE_10;
default:
return Node.NODE_1;
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions ios/RNVIClientModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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]]);
}
}
Expand Down
1 change: 1 addition & 0 deletions ios/RNVIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
+ (NSString *)convertQualityIssueLevelToString:(VIQualityIssueLevel)level;
+ (NSString *)convertQualityIssueTypeToString:(VIQualityIssueType)type;
+ (VIConnectionNode)convertConnectionNodeFromString:(NSString *)node;
+ (BOOL)validateConnectionNodeString:(NSString *)node;

@end

Expand Down
13 changes: 13 additions & 0 deletions ios/RNVIUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions react-native-voximplant.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Pod::Spec.new do |s|
s.name = 'react-native-voximplant'
s.author = { 'Zingaya Inc.' => '[email protected]' }
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 = {
Expand Down
11 changes: 8 additions & 3 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 04542cc

Please sign in to comment.