initiateCall static method

void initiateCall(
  1. Call call, {
  2. required dynamic onSuccess(
    1. Call call
    )?,
  3. required dynamic onError(
    1. 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()));
  }
}