Implement a complete calling workflow with ringing, incoming/outgoing call UI, accept, reject, and cancel functionality in CometChat React Native SDK.
Quick Reference - Initiate a call and listen for events:
Report incorrect code
Copy
Ask AI
// Initiate a video callconst call = new CometChat.Call("RECEIVER_ID", CometChat.CALL_TYPE.VIDEO, CometChat.RECEIVER_TYPE.USER);await CometChat.initiateCall(call);// Accept an incoming callawait CometChat.acceptCall(sessionId);// Reject or cancelawait CometChat.rejectCall(sessionId, CometChat.CALL_STATUS.REJECTED);
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 generate a call token and render the CometChatCalls.Component to join the call
Register the CallListener to receive real-time call events. Each listener requires a unique listenerId string to prevent duplicate registrations and enable targeted removal.
Always remove call listeners when the component unmounts using CometChat.removeCallListener(listenerId). Failing to do so can cause memory leaks and duplicate event handling.
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 presses 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 on component unmount to prevent memory leaks and duplicate events
Store the sessionId from initiateCall() or onIncomingCallReceived() — you’ll need it for accept, reject, cancel, and starting the session
Handle the CALL_STATUS_BUSY case when the receiver is already on another call
Call CometChat.clearActiveCall() and CometChatCalls.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
onIncomingCallReceived not firing: Ensure CometChat.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 rendering CometChatCalls.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
initiateCall fails 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 (not REJECTED) when the receiver is already on a call