Skip to main content
Quick Reference - Generate token and start a call session:

Overview

This section demonstrates how to start a call session in a React Native application. Previously known as Direct Calling.
Available via: SDK | UI Kits
Before you begin, we strongly recommend you read the calling setup guide.
If you want to implement a complete calling experience with ringing functionality (incoming/outgoing call UI), follow the Ringing guide first. Once the call is accepted, return here to start the call session.

Generate Call Token

A call token is required for secure access to a call session. Each token is unique to a specific session and user combination, ensuring that only authorized users can join the call. You can generate the token just before starting the call, or generate and store it ahead of time based on your use case. Use the generateToken() method to create a call token:
On SuccessgenerateToken() returns a GenerateToken object containing the session ID and JWT token:GenerateToken Object:

Start Call Session

Use the CometChatCalls.Component to render the call UI. This component requires a call token (generated in the previous step) and a CallSettings object that configures the call UI and behavior. The CallSettings class configures the call UI and behavior. Use CallSettingsBuilder to create a CallSettings instance.

Call Settings

Configure the call experience using the following CallSettingsBuilder methods:

Call Listeners

The OngoingCallListener provides real-time callbacks for call session events, including participant changes, call state updates, and error conditions. You can register listeners in two ways:
  1. Via CallSettingsBuilder: Use .setCallEventListener(listener) when building call settings
  2. Via addCallEventListener: Use CometChatCalls.addCallEventListener(listenerId, listener) to add multiple listeners
Each listener requires a unique listenerId string. This ID is used to:
  • Prevent duplicate registrations — Re-registering with the same ID replaces the existing listener
  • Enable targeted removal — Remove specific listeners without affecting others
Always remove call event listeners when the component unmounts using CometChatCalls.removeCallEventListener(listenerId). Failing to remove listeners can cause memory leaks and duplicate event handling.

Events

On EventonUserJoined returns a user object when a participant joins the call:User Object:
On EventonUserLeft returns a user object when a participant leaves the call:User Object:
On EventonUserListUpdated returns an array of all current participants in the call:User Array:User Object (each item in array):
On EventonAudioModesUpdated returns an array of available audio output modes:Audio Modes Array:Audio Mode Object (each item in array):
On EventonCallSwitchedToVideo is invoked when an audio call is upgraded to video. This event may not include additional data.

End Call Session

Ending a call session properly is essential to release media resources (camera, microphone, network connections) and update call state across all participants. The termination process differs based on whether you’re using the Ringing flow or Session Only flow.

Ringing Flow

When using the Ringing flow, you must coordinate between the CometChat Chat SDK and the Calls SDK to properly terminate the call and notify all participants.
The Ringing flow requires calling methods from both the Chat SDK (CometChat.endCall()) and the Calls SDK (CometChatCalls.endSession()) to ensure proper call termination and participant notification.
User who initiates the end call: When the user presses the end call button in the UI, the onCallEndButtonPressed() callback is triggered. You must call CometChat.endCall() inside this callback to properly terminate the call and notify other participants. On success, call CometChat.clearActiveCall() and CometChatCalls.endSession() to release resources.
On SuccessCometChat.endCall() returns a Call object with the final call status:Call Object (Root Level):
sender Object:
receiver Object:
data Object:data.entities Object:data.entities.by Object:data.entities.by.entity Object:data.entities.for Object:data.entities.for.entity Object:data.entities.on Object:data.entities.on.entity Object:
callInitiator Object:
callReceiver Object:
Remote participant (receives the onCallEnded() callback): Call CometChat.clearActiveCall() to clear the local call state, then call CometChatCalls.endSession() to release media resources.

Session Only Flow

When using the Session Only flow (direct call without ringing), you only need to call the Calls SDK method to end the session. There’s no need to notify the Chat SDK since no call signaling was involved. Call CometChatCalls.endSession() in the onCallEndButtonPressed() callback to release all media resources and disconnect from the call session.

Methods

These methods are available for performing custom actions during an active call session. Use them to build custom UI controls or implement specific behaviors based on your use case.
These methods can only be called when a call session is active.

Switch Camera

Toggles between the front and rear camera during a video call. Useful for allowing users to switch their camera view without leaving the call.

Mute Audio

Controls the local audio stream transmission. When muted, other participants cannot hear the local user.
  • true — Mutes the microphone, stops transmitting audio
  • false — Unmutes the microphone, resumes audio transmission

Pause Video

Controls the local video stream transmission. When paused, other participants see a frozen frame or avatar instead of live video.
  • true — Pauses the camera, stops transmitting video
  • false — Resumes the camera, continues video transmission

Set Audio Mode

Routes the audio output to a specific device. Use this to let users choose between speaker, earpiece, or connected audio devices. Available modes:
  • CometChat.AUDIO_MODE.SPEAKER — Device speaker (loudspeaker)
  • CometChat.AUDIO_MODE.EARPIECE — Phone earpiece
  • CometChat.AUDIO_MODE.BLUETOOTH — Connected Bluetooth device
  • CometChat.AUDIO_MODE.HEADPHONES — Wired headphones

Switch To Video Call

Upgrades an ongoing audio call to a video call. This enables the camera and starts transmitting video to other participants. The remote participant receives the onCallSwitchedToVideo() callback.

Get Audio Output Modes

Returns the list of available audio output devices. Use this to display audio options to the user and then set the selected mode using setAudioMode().
On SuccessgetAudioOutputModes() returns an object containing an array of available audio modes:Response Object:Mode Object (each item in modes array):

End Call

Terminates the current call session and releases all media resources (camera, microphone, network connections). After calling this method, the call view should be closed.

Best Practices

Call tokens are session-specific and time-limited. Generate them right before starting the call session rather than caching them for extended periods. This ensures the token is fresh and reduces the chance of token expiry errors.
When using the Ringing flow, remember to call both CometChat.endCall() and CometChatCalls.endSession(). Missing either call can leave the session in an inconsistent state — the Chat SDK may still show the call as active, or media resources may not be released properly.
Always remove call event listeners in your component’s cleanup function (e.g., the return function of useEffect). Orphaned listeners can cause memory leaks, duplicate event handling, and unexpected behavior when navigating between screens.
The CometChatCalls.Component should be rendered inside a View with height: '100%', width: '100%', and position: 'relative'. This ensures the call UI fills the screen correctly and overlays render in the right position.
When registering call event listeners with addCallEventListener, use a unique listenerId per component instance. This prevents one component from accidentally overwriting another component’s listener, especially in navigation stacks where multiple screens may be mounted simultaneously.

Troubleshooting

Ensure the user is logged in and the auth token is valid. Call CometChat.getLoggedinUser() to verify the user session is active. If the auth token has expired, re-authenticate the user before generating a call token.
Verify that the CometChatCalls.Component is wrapped in a View with explicit dimensions (height: '100%', width: '100%'). The component requires a sized container to render. Also confirm that both callSettings and callToken props are provided and not null or undefined.
Check that the listener is registered before the call session starts. If using addCallEventListener, ensure the listenerId is unique and hasn’t been overwritten by another registration. Also verify that the Calls SDK has been initialized via CometChatCalls.init().
The onCallEnded callback only fires for 1:1 calls (exactly 2 participants). For group calls, use onUserLeft and onUserListUpdated to track when participants leave, and handle session cleanup based on your app’s logic.
Check device permissions for camera and microphone. On React Native, you need to request CAMERA and RECORD_AUDIO permissions on Android, and add NSCameraUsageDescription and NSMicrophoneUsageDescription to Info.plist on iOS. Also verify that setIsAudioOnlyCall matches your intended call type.

Next Steps

Ringing

Implement a complete calling experience with incoming and outgoing call UI

Recording

Record call sessions for playback and compliance

Video View Customisation

Customize the main video container and participant tiles

Presenter Mode

Enable screen sharing and presenter layouts in calls