initCometChatCalls method
void
initCometChatCalls(
- CallAppSettings callAppSettings,
- dynamic onSuccess(
- String success
- dynamic onError()
override
Implementation
@override
void initCometChatCalls(callAppSettings, onSuccess, onError) async {
try{
CometChatCallsUtils.showLog(tag, "initCometChatCalls: CALLED");
if(callAppSettings.appId == null){
onError(CometChatCallsException(CometChatCallsConstants.codeCometChatCallsSDKInitError, "App ID is null, please set the App Id first", "App ID is null, please set the App Id first"));
}else if(callAppSettings.region == null){
onError(CometChatCallsException(CometChatCallsConstants.codeCometChatCallsSDKInitError, "Region is null, please set the region first", "App ID is null, please set the App Id first"));
}else{
final result = await methodChannel.invokeMethod<Map>('initCometChatCalls', {
"appID": callAppSettings.appId,
"region": callAppSettings.region,
"host": callAppSettings.host
});
CometChatCallsUtils.showLog(tag, "initCometChatCalls: RESULT: $result");
if (result == null) {
onError(CometChatCallsException(CometChatCallsConstants.codeCometChatCallsSDKInitError, "CometChatCalls SDK is not initialized, requested result is null", "CometChatCalls SDK is not initialized, requested result is null"));
}else{
ApiConnection.callAppSettings = callAppSettings;
onSuccess(result["message"]);
}
}
} on PlatformException catch (platformException) {
onError(CometChatCallsException(platformException.code, platformException.message, platformException.details));
} catch (e) {
onError(CometChatCallsException(CometChatCallsConstants.codeError, e.toString(), e.toString()));
}
}