- Alex initiates the call to Bob using the initiateCall() method.
-
Bob now has two choices:
- Accept the call from Alex using the acceptCall() method.
- Reject the call from Alex using the rejectCall() method passing the status as
rejected.
-
In the meantime, Alex has the option to cancel the call he initiated to Bob using the rejectCall() method passing the status as
cancelled. -
If Bob accepts the call from Alex, both Alex and Bob need to call the startCall() method. Alex in the onOutgoingCallAccepted() method of the
CallListenerand Bob in the success obtained from the acceptCall() method and both will be connected to each other.
Initiate Call
TheinitiateCall() method sends a call request to a user or a group.
- User Call
- Group Call
- User Call (Typescript)
- Group Call (Typescript)
Call class. The constructor for Call class takes the following parameters:
On successful initialization, a
Call object is returned with the details of the call including a unique session ID for the call.
Receive Calls
Wherever you wish to receive the call events in, you need to register theCallListener listener using the addCallListener() method.
- Receive Calls
- TypeScript
We recommend you remove the listener once the activity or fragment is not in use.
- Remove Call Listener
- TypeScript
- The receiver of the call accepts the call.
- The receiver of the call rejects the call.
- The initiator of the call cancels the call.
Accept the Incoming Call
Once you have received an incoming call from a user or in any group, to accept the call using theacceptCall() method.
- Accept Incoming Call
- TypeScript
Reject the Incoming Call
To reject the incoming call once it is received using therejectCall() method.
- Reject Incoming Call
- TypeScript
Here the status needs to be set as
CometChat.CALL_STATUS.REJECTED as the call is being rejected by the receiver of the call.
Cancel the Outgoing Call
In the case where the initiator wishes to cancel the call, use the same aboverejectCall() method and just pass the status to the rejectCall() method as CometChat.CALL_STATUS.CANCELLED
Start a Call
Once the call request is sent and the receiver has accepted the call, both the initiator and the receiver need to call thestartCall() method.
You need to call this method for two scenarios:
- After you accept an incoming call i.e. in the
onSuccess()callback of theacceptCall()method. - After the recipient accepts an outgoing call i.e. in the
onOutgoingCallAccepted()callback of theCallListenerlistener.
- Start a Call
- TypeScript
The current
startCall() method which takes the sessionId, view, Ongoing Call Listener to load the call view is deprecated and will be replaced in the future versions. It will continue to work on this version but we suggest moving to the new method as shown above using the object of the CallSettings class as the parameter.
The
OngoingCallListener listener provides you with the below callback methods:
Settings
TheCallSettings class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the CallSettingsBuilder class. This will eventually give you an object of the CallSettings class which you can pass to the startCall() method to start the call.
The mandatory parameters that are required to be present for any call/conference to work are:
- sessionId - The unique session Id for the call/conference session.
In case you wish to achieve a completely customized UI for the Calling experience, you can do so by embedding default android buttons to the screen as per your requirement and then use the below methods to achieve different functionalities for the embedded buttons.
For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat, you can embed the buttons in your layout and use the below methods to perform the corresponding operations:
Mute Audio
You can call themuteAudio(mute: boolean) method to mute/unmute your audio stream.
- Mute Audio
- TypeScript
true the audio stream will be muted and if set to false the audio stream will be unmuted.
Pause Video
You can call thepauseVideo(pause: boolean) method to pause/unpause video stream.
- Pause Video
- TypeScript
true the video stream will be paused and if set to false the video stream will be unpaused.
Start Screen Share
You can callstartScreenShare() to start the screen share.
Stop Screen Share
You can callstopScreenShare() to stop the screen share.
Set Mode
You can use thesetMode(mode: string) method to set the mode.
- Set Mode
- TypeScript
Get Audio Input Devices
You can use thegetAudioInputDevices() method to get all the available audio input devices.
- Get Audio Input Devices
- TypeScript
Get Audio Output Devices
You can use thegetAudioOutputDevices() method to get all the available audio output devices.
- Get Audio Output Devices
- TypeScript
Get Video Input Devices
You can use thegetVideoInputDevices() method to get all the available video input devices.
- Get Video Input Devices
- TypeScript
Set Audio Input Device
You can use thesetAudioInputDevice(deviceId) method to set the active audio input device.
- Set Audio Input Device
- TypeScript
Set Audio Output Device
You can use thesetAudioOutputDevice(deviceId) method to set the active audio output device.
- Set Audio Output Device
- TypeScript
Set Video Input Device
You can use thesetVideoInputDevice(deviceId) method to set the active video input device.
- Set Video Input Device
- TypeScript
Switch To Video Call
You can use theswitchToVideoCall() method to switch from audio call to video call.
- JavaScript
- TypeScript
End Call
You can use theCometChat.endCall() method of the CometChat class to end the call.
- End Call
- TypeScript
Active Call
CometChat provides a method to get the details of the call that is currently active. TheCometChat.getActiveCall() will return an object of the Call class containing the details of the ongoing call. If there is no ongoing call this method will return null.
- Get Active Call
- TypeScript
The
getActiveCall() method will only return the details of the active call for the ongoing session in which the call has been started. If the app is restarted, the data will be lost.Call Participant Count
In order to get the number of participants in any call, you can use thegetCallParticipantCount() method. This method takes the session id for the call and returns the number of participants that are active in the call.
- Get Call Participant Count
- TypeScript