Overview
This section explains how to implement a complete calling workflow with ringing functionality, including incoming/outgoing call UI, call acceptance, rejection, and cancellation. Previously known as Default Calling.After the call is accepted, you need to start the call session. See the Call Session guide for details on starting and managing the actual call.
- Caller initiates a call using
initiateCall() - Receiver gets notified via
onIncomingCallReceived()callback - Receiver can either:
- Accept the call using
acceptCall() - Reject the call using
rejectCall()with statusCALL_STATUS_REJECTED
- Accept the call using
- Caller can cancel the call using
rejectCall()with statusCALL_STATUS_CANCELLED - Once accepted, both participants call
startSession()to join the call
Initiate Call
TheinitiateCall() method sends a call request to a user or a group. On success, the receiver gets an onIncomingCallReceived() callback.
- User Call (JavaScript)
- Group Call (JavaScript)
- User Call (TypeScript)
- Group Call (TypeScript)
| Parameter | Description |
|---|---|
receiverID | The UID or GUID of the recipient |
receiverType | CometChat.RECEIVER_TYPE.USER or CometChat.RECEIVER_TYPE.GROUP |
callType | CometChat.CALL_TYPE.AUDIO or CometChat.CALL_TYPE.VIDEO |
Call object is returned containing the call details including a unique sessionId required for starting the call session.
Call Listeners
Register theCallListener to receive real-time call events. Each listener requires a unique listenerId string to prevent duplicate registrations and enable targeted removal.
- JavaScript
- TypeScript
Events
| Event | Description |
|---|---|
onIncomingCallReceived(call) | Invoked when an incoming call is received. The call contains caller details, session ID, and call type. Display incoming call UI here. |
onOutgoingCallAccepted(call) | Invoked on the caller’s device when the receiver accepts. Generate call token and start the session here. |
onOutgoingCallRejected(call) | Invoked on the caller’s device when the receiver rejects the call. Dismiss outgoing call UI here. |
onIncomingCallCancelled(call) | Invoked on the receiver’s device when the caller cancels before answering. Dismiss incoming call UI here. |
onCallEndedMessageReceived(call) | Invoked when a call ends. The call contains final status and duration. Update call history here. |
Accept Call
When an incoming call is received viaonIncomingCallReceived(), use acceptCall() to accept it. On success, start the call session.
- JavaScript
- TypeScript
Reject Call
UserejectCall() to reject an incoming call. Set the status to CALL_STATUS_REJECTED.
- JavaScript
- TypeScript
Cancel Call
The caller can cancel an outgoing call before it’s answered usingrejectCall() with status CALL_STATUS_CANCELLED.
- JavaScript
- TypeScript
Start Call Session
Once the call is accepted, both participants need to start the call session. Caller flow: In theonOutgoingCallAccepted() callback, generate a token and start the session.
Receiver flow: In the acceptCall() success callback, generate a token and start the session.
- JavaScript
- TypeScript
End Call
To end an active call in the ringing flow, the process differs based on who ends the call. User who ends the call: When the user presses the end call button, theonCallEndButtonPressed() callback is triggered. Inside this callback, call CometChat.endCall() to notify other participants. On success, call CometChat.clearActiveCall() and CometChatCalls.endSession() to release resources.
- JavaScript
- TypeScript
onCallEnded() callback):
- JavaScript
- TypeScript
Busy Call Handling
If the receiver is already on another call, you can reject the incoming call withCALL_STATUS_BUSY status.
- JavaScript
- TypeScript