Audio Calling

Warning! This documentation is outdated. Please refer to our new documentation at docs.cometchat.com.

Warning! This documentation is outdated. Please refer to our new documentation at docs.cometchat.com.

To use Audio call functionality, you must download Audio/Video chat enabled SDK and enable the Audio chat plugin from CometChat administration panel. To start using Audio call functionality you must have AudioChat instance which can be obtained as follows:

AudioChat audiochat = AudioChat.getInstance(context)

1. Send call request
To start with Audio call, you need to send a request to the other user. The syntax is as follows:

Pass the user id from whom you have received the request. Pass the callid you receive from the request you received in onAvchatMessageReceived() callback. You will get success response containing the user id whose request you have rejected.

{ "id":"15"}

4. Cancel request
You can cancel the call request which you have sent by using the function cancelAudioChatRequest() function, the syntax is as follows:

Pass the user id with whom the call is going on and callid of current on-going call. You will get success response containing the user id with whom the call is ended.

{ "id":"15"}

7. Send busy response
Audio calling is limited to only one user, so if any other user calls you while you are having a call going on, then you can send the busy response to the user by using sendBusyTone() function. The syntax is as follows:

Pass the user id with whom you wish to send the busy tone. You will get success response containing the user id.

{ "id":"15"}

8. Send no answer response
You can implement a functionality like if the call is not accepted for a particular time period then you can send no answer response to the callee. For this, you can use sendNoAnswerCall() function. The syntax is as follows:

Pass the user id with whom you wish to send the no answer response. You will get success response containing the user id.

{ "id":"15"}

9. Toggle audio
While having Audio call you can turn on/off the audio, so that other user can not listen to your voice. For this, you can use the toggleAudio() function. The syntax is as follows:

toogleAudio(Boolean flag)

10. Switch Speakers
While having Audio call, you can switch the audio between the main speaker and callee speaker (ear speaker), this will enhance your Audio call experience. For this, you can use the switchSpeakers() function. The syntax is as follows:

switchSpeakers(Callbacks callbacks)

This will toggle between the main speaker and ear speaker. In success callback you will get jsonObject response as follows: