Audio Call

To add Audio Calling support in your application,

Include the class by writing

using MessageSDKFramework;

in your class.

Initialize the AudioChat object:

AudioChat audioChat = new AudioChat();

Method Available:

Method Description
sendAudioChatRequest The method sends audio call resquest to a user from a logged-in user
acceptAudioChatRequest The method allows logged-in user to accept an audio call
startAudioChatCall The method allows loggedin user to start audio call
endAudioChatCall The method allows you end the call
cancelAudioChatRequest The method allows initiator to call the outgoing call
SendBusyAudioTone The method allows you to send busy notification to a user
rejectAudioChatRequest The method allows you to reject an incoming call
muteAudio The method allows you to mute/unmute audio

sendAudioChatRequest

The method sends audio call resquest to a user from a logged-in user
Method Signature:

public virtual void sendAudioChatRequest(
                             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 audio call request is sent successfully
Response: NSDictionary containing id of the user to whom audio 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 audio call request
Response: NSError containing error code and message

Usage:

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

acceptAudioChatRequest

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

public virtual void acceptAudioChatRequest(
                             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 audio call acknowledgement successfully
Response: NSDictionary containing id of the user to whom audio 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 audio call acknowledgement
Response: NSError containing error code and message

Usage:

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

StartAudioChatCall

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

public virtual void StartAudioChatCall(
                             string userID,
                             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 audio 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 audio call request
Response: NSError containing error code and message

Usage:

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

EndAudioChatCall

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

public virtual void EndAudioChatCall(
                             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 audio call successfully
Response: NSDictionary containing id of the user and callID corresponding to the ended audio 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 audio call session
Response: NSError containing error code and message

Usage:

cometchat.EndAudioChatCall("6","474a3e0baf0e3db251a2bc2a6a5b31a5",this,
                   (dict) => { this.response(dict); /* code block */ },
                   (err) => { this.failure(err); /* code block */ }
                   );

CancelAudioChatRequest

Allows initiator to call the outgoing call
Method Signature:

public virtual void CancelAudioChatRequest(
                             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 audio call successfully
Response: NSDictionary containing id of the user with whom audio 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 audio call request
Response: NSError containing error code and message

Usage:

cometchat.CancelAudioChatRequest("6",
                   (dict) => { this.response(dict); /* code block */ },
                   (err) => { this.failure(err); /* code block */ }
                   );

SendBusyAudioTone

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 AUDIO_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 SendBusyAudioTone(
                             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:

cometchat.SendBusyAudioTone("6",
                   (dict) => { this.response(dict); /* code block */ },
                   (err) => { this.failure(err); /* code block */ }
                   );

rejectAudioChatRequest

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

public virtual void RejectAudioChatRequest(
                             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 rejecting audio call successfully
Response: NSDictionary containing id of the user whose incoming audio 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:

cometchat.RejectAudioChatRequest("6",
                   (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:

cometChat.MuteAudio(true);

Please refer ‎error codes for failure responses.

  • Was this helpful?
  • Yes   No