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.
Call Flow:
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 status CALL_STATUS_REJECTED
Caller can cancel the call using rejectCall() with status CALL_STATUS_CANCELLED
Once accepted, both participants call startSession() to join the call
CometChat.RECEIVER_TYPE.USER or CometChat.RECEIVER_TYPE.GROUP
callType
CometChat.CALL_TYPE.AUDIO or CometChat.CALL_TYPE.VIDEO
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 (TypeScript)
User Call (JavaScript)
Group Call (TypeScript)
Group Call (JavaScript)
const receiverID: string = "UID";const callType: string = CometChat.CALL_TYPE.VIDEO;const receiverType: string = CometChat.RECEIVER_TYPE.USER;const call: CometChat.Call = new CometChat.Call(receiverID, callType, receiverType);// Set a custom timeout of 60 secondsCometChat.initiateCall(call, 60).then( (outgoingCall: CometChat.Call) => { console.log("Call initiated with 60s timeout:", outgoingCall); }, (error: CometChat.CometChatException) => { console.log("Call initiation failed:", error); });
const receiverID = "UID";const callType = CometChat.CALL_TYPE.VIDEO;const receiverType = CometChat.RECEIVER_TYPE.USER;const call = new CometChat.Call(receiverID, callType, receiverType);// Set a custom timeout of 60 secondsCometChat.initiateCall(call, 60).then( (outgoingCall) => { console.log("Call initiated with 60s timeout:", outgoingCall); }, (error) => { console.log("Call initiation failed:", error); });
const receiverID: string = "GUID";const callType: string = CometChat.CALL_TYPE.VIDEO;const receiverType: string = CometChat.RECEIVER_TYPE.GROUP;const call: CometChat.Call = new CometChat.Call(receiverID, callType, receiverType);// Set a custom timeout of 60 secondsCometChat.initiateCall(call, 60).then( (outgoingCall: CometChat.Call) => { console.log("Call initiated with 60s timeout:", outgoingCall); }, (error: CometChat.CometChatException) => { console.log("Call initiation failed:", error); });
const receiverID = "GUID";const callType = CometChat.CALL_TYPE.VIDEO;const receiverType = CometChat.RECEIVER_TYPE.GROUP;const call = new CometChat.Call(receiverID, callType, receiverType);// Set a custom timeout of 60 secondsCometChat.initiateCall(call, 60).then( (outgoingCall) => { console.log("Call initiated with 60s timeout:", outgoingCall); }, (error) => { console.log("Call initiation failed:", error); });
Parameter
Type
Description
call
Call
The call object created with receiver ID, call type, and receiver type.
timeout
number
Optional. The ringing duration in seconds before an unanswered call is automatically cancelled. Default: 45.
Register the CallListener to receive real-time call events. Each listener requires a unique listenerId string to prevent duplicate registrations and enable targeted removal.
Once the call is accepted, both participants need to start the call session.Caller flow: In the onOutgoingCallAccepted() callback, generate a token and start the session.Receiver flow: In the acceptCall() success callback, generate a token and start the session.
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 clicks the end call button, the onCallEndButtonPressed() callback is triggered. Inside this callback, call CometChat.endCall() to notify other participants. On success, call CometChat.clearActiveCall() and CometChatCalls.endSession() to release resources.
Always remove call listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.