Audio/Video Calling

To add Audio/Video Calling support in your application,

Include CustomUI.js in your index.html file to access the Custom UI functionality in your Cordova app

All the method calls will invoke their respective callback blocks as defined below.

1. Send call request
Send Audio Video call request to the userID specified. (Ensure that userID cannot be nil or empty)


function callbackmeth(result){

  alert(result);

}

CustomUI.sendAVChatRequestToUser("5",callbackmeth);

(i).
Invocation: After audio video call request is sent successfully
Response: Callback containing id of the user to whom audio video call request has been sent
Eg:

"success"={
  callID = "\"474a3e0baf0e3db251a2bc2a6a5b31a5\"";  
  userID = 5;
}

2. Accept call request
Accept audio-video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL message and also userID cannot be nil or empty)


function callbackmeth(result){

  alert(result);

}

CustomUI.acceptAVChatRequestOfUser("6","474a3e0baf0e3db251a2bc2a6a5b31a5",callbackmeth);

Invocation: After sending audio video call acknowledgement request successfully
Response: Callback containing id of the user to whom audio video call acknowledgement has been sent
Eg:

"success"={  
 userID = 6;
}

3. Start audio video call
Start an audio-video call within the container view. This function has to be called after sending/accepting audio-video call request only. (Ensure that userID specified here should be the same while sending/accepting the request and also userID cannot be nil or empty)


function callbackmeth(result){

  alert(result);

}

CustomUI.startAVChatWithCallID("6",this,callback);

4. End call
End audio-video call with the user corresponding to userID specified. (Ensure that userID specified should be same as given when starting the audio-video call and also userID cannot be nil or empty)


function callbackmeth(result){

  alert(result);

}

CustomUI.endAVChatWithUser("6",callbackmeth);

Invocation: After ending audio video call successfully
Response: Callback containing id of the user with whom audio video call has been ended
Eg:

"success"={  
 callID = 474a3e0baf0e3db251a2bc2a6a5b31a5;
 userID = 6;
}

5. Cancel call
Cancel audio-video call after sending a call request. (Ensure that userID specified should be same as given when sending the audio-video call request and also userID cannot be nil or empty)


function callbackmeth(result){
   alert(result);
}

CustomUI.cancelAVChatRequestWithUser("6",callbackmeth);

Invocation: After cancelling audio video call successfully
Response: NSDictionary containing id of the user with whom audio video call has been cancelled
Eg:

"success"={  
  userID = 6;
}

6. Send busy call
Send busy call when AVCHAT_INCOMING_CALL_USER_BUSY message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL_USER_BUSY message and also userID cannot be nil or empty)


function callbackmeth(result){
   alert(result);
}
CustomUI.sendBusyAVCallToUser("5",callbackmeth);

Invocation: After sending busy call successfully
Response: NSDictionary containing id of the user to whom busy tone has been sent
Eg:

"success"={  
  userID = 6;
}

7. Reject call
Reject audio-video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL message and also userID cannot be nil or empty)


function callbackmeth(result){
   alert(result);
}

CustomUI.rejectAVChatRequestOfUser("5",callbackmeth);

Invocation: After rejecting audio video call successfully
Response: NSDictionary containing id of the user whose incoming audio video call request has been
rejected
Eg:

"success"={ 
 callID = 474a3e0baf0e3db251a2bc2a6a5b31a5; 
 userID = 5;
}

8. Toggle Audio to ON(YES) or OFF(NO) state


function callbackmeth(result){
  alert(result);
}

CustomUI.toggleAudioSDK(true,callbackmeth);

9. Toggle Video to ON(YES) or OFF(NO) state


function callbackmeth(result){
  alert(result);
}

CustomUI.toggleVideoSDK(true,callbackmeth);

10. Switch between front and rear camera in a Video call


function callbackmeth(result){
  alert(result);
}

CustomUI.switchCameraSDK(callbackmeth);

Please refer ‎error codes for failure responses.

Not finding what you need?

The CometChat team is here to help!