initiateCall static method
void
initiateCall(
- Call call, {
- required dynamic onSuccess(
- Call call
- required dynamic onError(
- CometChatException excep
Implementation
static void initiateCall(Call call , {
required Function(Call call)? onSuccess,
required Function(CometChatException excep) onError
}) async {
try {
if(call.receiverUid.isEmpty){
onError(CometChatException("Error", "User auth toke is null", "User is not logged in"));
}else if(call.receiverType.isEmpty){
onError(CometChatException("Error", "User auth toke is null", "User is not logged in"));
}else if(call.type.isEmpty){
onError(CometChatException("Error", "User auth toke is null", "User is not logged in"));
}else{
var result = await channel.invokeMethod('initiateCall', {
"receiverUid": call.receiverUid,
"receiverType": call.receiverType,
"callType": call.type,
});
if(onSuccess != null) onSuccess(Call.fromMap(result));
}
}on PlatformException catch (exception) {
onError(CometChatException(exception.code, exception.message, exception.details));
} catch (e) {
onError(CometChatException("Error", "Something went wrong", e.toString()));
}
}