Video Call

To add Audio/Video Calling support in your app,

Include the class CometChat

using MessageSDKFramework;

Initialize the AVChat object:

CometChat avChat;

Methods Available:

Method Description
sendAVChatRequestToUser The method allows user to initiate video call resquest to a user from a logged-in user
acceptAVChatRequestOfUser The method allows logged-in user to accept an video call
startAVChatWithCallID The method allows loggedin user to start video call
endAVChatWithUser The method allows you end the call
cancelAVChatCallWithUser The method allows initiator to call the outgoing call
sendBusyCallToUser The method allows you to send busy notification to a user
rejectAVChatCallWithUser The method allows you to reject an incoming call
toggleAudio The method allows you to mute/unmute audio
toggleVideo The method allows you to mute/unmute video
switchCamera The method allows you to switch camera

sendAVChatRequest

The method initiates video call resquest to a user from a logged-in user
Method Signature:

 public virtual void SendAVChatRequest(
                                string userId,
                                Action < NSDictionary > response,
                                Action < NSError> failure
            )

Arguments:

userID:

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After video call request is sent successfully
Response: NSDictionary containing id of the user to whom video call request has been sent and callID

Sample Response:

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

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

 avchat.SendAVChatRequest("5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

acceptAVChatRequest

Allows you to accept an video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback of subscribeWithMode method of CometChat class.
Method Signature:

 public virtual void AcceptAVChatRequest(
                                string userId,
                                string callId,
                                Action < NSDictionary > response,
                                Action < NSError > failure
            )

Arguments:

userID

The userid of a user who has initiated a call with you as NSString datatype.

callID

The id of the incoming call

success

A callback method.

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After sending video call acknowledgement successfully
Response: NSDictionary containing id of the user to whom video call acknowledgement has been sent

Sample Response:

{  
 userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending video call acknowledgement
Response: NSError containing error code and message

Usage:

avchat.AcceptAVChatRequest("5","474a3e0baf0e3db251a2bc2a6a5b31a5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

StartAVChatCall

Starts an video call within a container view. This function has to be called after sending/accepting video call request only.
Method Signature:

 public virtual void StartAVChatCall(
                                string callId,
                                NSObject container,
                                Action < NSDictionary > response,
                                Action < NSError > failure
                                )

Arguments:

callID

The id of the call as NSString datatype.

inContainerView

The reference of the UI Container in which video call UI should be placed as UIView datatype.

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

avchat.StartAVChatCall("5",this,
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

EndAVChatCall

Ends an video call corresponding to userID and callID
Method Signature:

public virtual void EndAVChatCall(
                               string userId,
                               string callId,
                               Action < NSDictionary > response,
                               Action < NSError > failure
                               )

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

callID

The id of a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After ending video call successfully
Response: NSDictionary containing id of the user and callID corresponding to the ended video call session

Sample Response:

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

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while ending video call session
Response: NSError containing error code and message

Usage:

avchat.EndAVChatCall("5","474a3e0baf0e3db251a2bc2a6a5b31a5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

CancelAVChatRequest

Allows initiator to call the outgoing call
Method Signature:

public virtual void CancelAVChatRequest(
                               string userId,
                               Action < NSDictionary > response,
                               Action < NSError > failure
                               )

Arguments:

userID

The userid of a user with whom you had initiated a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After cancelling video call successfully
Response: NSDictionary containing id of the user with whom video call has been cancelled

Sample Response:

{
  userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

avchat.CancelAVChatRequest("5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

SendBusyAVChatTone

Sends busy call notification to a user who had made a call. You can use this method to notify the user that you are already enganed in another call. The message AVCHAT_INCOMING_CALL_USER_BUSY message is received in the onAVChatMessageReceived callback indicates that the logged-in user is busy with another call.
Method Signature:

 public virtual void SendBusyAVChatTone(
                                string userId,
                                Action < NSDictionary > response,
                                Action < NSError > failure
                                )

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After sending busy call successfully
Response: NSDictionary containing id of the user to whom busy notification has been sent

Sample Response:

{  
  userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending busy notification
Response: NSError containing error code and message

Usage:

avchat.SendBusyAVChatTone("5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

RejectAVChatRequest

Allows user to reject video call. You can show an option to reject a call on receiving AVCHAT_INCOMING_CALL_USER_BUSY message in the onAVChatMessageReceived callback.
Method Signature:

 public virtual void RejectAVChatRequest(
                                string userId,
                                string callId,
                                Action < NSDictionary > response,
                                Action < NSError > failure
                                )

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method

Method Property Description
Method Signature: private void response(NSDictionary dict)
Invocation: After rejecting video call successfully
Response: NSDictionary containing id of the user whose incoming video call request has been rejected

Sample Response:

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

failure

A callback method.

Method Property Description
Method Signature: private void failure(NSError err)
Invocation: If an error occurs while sending busy notification
Response: NSError containing error code and message

Usage:

avchat.RejectAVChatRequest("5","474a3e0baf0e3db251a2bc2a6a5b31a5",
                           (dict) => { this.response(dict); /* code block */ }, 
                           (err) => { this.failure(err); /* code block */ }
                           );

muteAudio

The method allows user to mute/unmute Audio
Method Signature:

public virtual void MuteAudio( bool audioControlFlag );

Arguments:

audioControlFlag:

A boolean value. YES indicates unmute and NO indicates mute
Usage:

avchat.MuteAudio(true);

pauseVideo

The method allows user to mute/unmute video
Method Signature:

public virtual void pauseVideo( bool videoControlFlag );

Arguments:

videoControlFlag

A boolean value. YES indicates unmute and NO indicates mute
Usage:

avChat.pauseVideo(true);

switchCamera

The method allows user to switch camera
Method Signature:

public virtual void toggleCamera();

Usage:

avChat.toggleCamera();

Please refer ‎error codes for failure responses.

  • Was this helpful?
  • Yes   No