Quick Reference - Initiate a call and listen for events:
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 generate a call token and render the
CometChatCalls.Componentto 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)
On success, a
Call object is returned containing the call details including a unique sessionId required for starting the call session.
By default, an unanswered call automatically cancels after 45 seconds. You can customize this duration by passing an optional timeout parameter (in seconds) as the second argument to initiateCall().
- User Call (JavaScript)
- Group Call (JavaScript)
- User Call (TypeScript)
- Group Call (TypeScript)
Response
Response
On Success —
initiateCall() returns a Call object with session details:User Object Structure:
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
Response
Response
On Event —
On Event —
On Event —
On Event —
onIncomingCallReceived returns a Call object (same structure as initiateCall response):On Event —
onOutgoingCallRejected / onIncomingCallCancelled returns a Call object with status: "unanswered":On Event —
onOutgoingCallAccepted returns a Call object with status: "ongoing":On Event —
onCallEndedMessageReceived returns a Call object with status: "ended":User Object Structure:
Accept Call
When an incoming call is received viaonIncomingCallReceived(), use acceptCall() to accept it. On success, start the call session.
- JavaScript
- TypeScript
Response
Response
On Success —
acceptCall() returns a Call object with status: "ongoing":User Object Structure:
Reject Call
UserejectCall() to reject an incoming call. Set the status to CALL_STATUS_REJECTED.
- JavaScript
- TypeScript
Response
Response
On Success —
rejectCall() with REJECTED status returns a Call object:User Object Structure:
Cancel Call
The caller can cancel an outgoing call before it’s answered usingrejectCall() with status CALL_STATUS_CANCELLED.
- JavaScript
- TypeScript
Response
Response
On Success —
rejectCall() with CANCELLED status returns a Call object:User Object Structure:
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
Response
Response
On Success —
On Event —
On Event —
On Event —
generateToken() returns an object with session and token:On Event —
onUserJoined returns user info when a participant joins:On Event —
onUserListUpdated returns the current list of participants:Each participant object:
On Event —
onUserLeft returns user info when a participant leaves: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
Response
Response
On Success —
endCall() returns a Call object with status: "ended":User Object Structure:
Busy Call Handling
If the receiver is already on another call, you can reject the incoming call withCALL_STATUS_BUSY status.
- JavaScript
- TypeScript
Response
Response
On Success —
On Event — The caller receives
rejectCall() with BUSY status returns a Call object:On Event — The caller receives
onOutgoingCallRejected with status: "busy":User Object Structure:
Best Practices
Best Practices
- Always remove call listeners on component unmount to prevent memory leaks and duplicate events
- Store the
sessionIdfrominitiateCall()oronIncomingCallReceived()— you’ll need it for accept, reject, cancel, and starting the session - Handle the
CALL_STATUS_BUSYcase when the receiver is already on another call - Call
CometChat.clearActiveCall()andCometChatCalls.endSession()together when a call ends to properly release all resources - Request camera and microphone permissions before initiating or accepting a call
- Show appropriate UI feedback (spinner, ringing animation) while waiting for the receiver to respond
Troubleshooting
Troubleshooting
onIncomingCallReceivednot firing: EnsureCometChat.addCallListener()is registered before the call is initiated and that the listener ID is unique- Call accepted but no audio/video: After
acceptCall(), you must start the call session by generating a token and renderingCometChatCalls.Component— see the Start Call Session section above - Duplicate call events: You may have registered the same listener multiple times — always call
CometChat.removeCallListener(listenerId)on unmount initiateCallfails with error: Verify the receiver UID/GUID exists and that the logged-in user has an active session- Call ends immediately after accept: Make sure both caller and receiver generate a call token and render
CometChatCalls.Component— if only one side renders the component, the call will appear to drop - Busy status not working: Ensure you’re using
CometChat.CALL_STATUS.BUSY(notREJECTED) when the receiver is already on a call
Next Steps
Call Session
Start and manage the actual call session after the ringing flow completes.
Calls SDK Setup
Install dependencies, configure permissions, and initialize the Calls SDK.
Recording
Record audio and video calls for playback or compliance.
Call Logs
Retrieve and display call history including duration and participants.