Skip to main content
The CometChatOngoingCall component shows the screen users see during a voice or video call. It requests a call token for the session, then renders the Calls SDK call view, with video tiles and call controls such as mute, pause video, switch camera, and end call. Until the token arrives, it shows a loading spinner.

Usage

Integration

CometChatIncomingCall and CometChatOutgoingCall render CometChatOngoingCall for you once a call connects, so most apps never render it directly. Render it yourself when you build your own call flow. Pass the call’s session ID and a CometChatCalls.CallSettingsBuilder. Set an OngoingCallListener on the builder so your app knows when the call ends.
This listener takes the same steps as CometChatIncomingCall when a call ends.
The component fills its parent, so render it full screen, for example inside a React Native Modal as CometChatOutgoingCall does.

Actions

Actions dictate how a component functions. CometChatOngoingCall has one user-defined action.

1. onError

Fires when the component cannot get a call token: no user is logged in, or CometChat.getLoggedinUser() or CometChatCalls.generateToken() fails. A plain JavaScript Error, such as the one for no logged-in user, arrives as a CometChatException with the code TOKEN_GENERATION_FAILED.
Errors during the call are not sent to this prop. They go to the onError handler of the OngoingCallListener on your builder. CometChatOngoingCall has no call-ended action. To act when the call ends, set onCallEnded on the builder’s OngoingCallListener, as shown in Integration.

Filters

Filters narrow the data a component shows. CometChatOngoingCall shows no list. Instead, callSettingsBuilder controls the call itself.

1. CallSettingsBuilder

CometChatCalls.CallSettingsBuilder from @cometchat/calls-sdk-react-native offers these methods:

Example

In the example below, the call shows the recording button and starts with audio muted:
Voice and video calls need microphone and camera permissions on iOS and Android. Add them as described in Add Permissions.

Events

Events are emitted by a component. CometChatOngoingCall emits no events of its own. When CometChatIncomingCall or CometChatOutgoingCall render it for you, they emit this event when the call ends:
If you render CometChatOngoingCall yourself, nothing emits this event. Use onCallEnded on your builder’s OngoingCallListener instead.

Customization

To fit your app’s requirements, you can customize how the call behaves through the component’s props and callSettingsBuilder.

Style

CometChatOngoingCall has no style prop. The Calls SDK draws the call screen. The only UI Kit element is the loading spinner, which uses the theme’s primary color.

Functionality

  • callSettingsBuilder must be a CometChatCalls.CallSettingsBuilder instance, because the component calls its build() method. A plain settings object does not work.
  • The call uses the settings built on the component’s first render. Passing a different builder later has no effect.

Advanced

For advanced customization, UI Kit components accept custom views for parts of their UI. CometChatOngoingCall has no view slots, so it offers no customization beyond callSettingsBuilder.

Common Patterns

Show the Ongoing Call After Accepting a Call

Accept the call with the Chat SDK, then render the call screen for the accepted call. This mirrors what CometChatIncomingCall does by default.

Configure Call Settings for a Video Call

When you render CometChatOngoingCall yourself, also set the OngoingCallListener from Integration.

Audio-Only Call Configuration

When you render CometChatOngoingCall yourself, also set the OngoingCallListener from Integration.

Listen for Call End Events

How you learn that a call ended depends on what renders the call screen:
  • You render CometChatOngoingCall: set onCallEnded on the builder’s OngoingCallListener, as in Integration.
  • CometChatIncomingCall or CometChatOutgoingCall renders it: listen for ccCallEnded, as in Events.

Use Your Own Settings with Incoming Call, Outgoing Call or Call Buttons

These components take a builder for the call screen they open: Two things differ from rendering CometChatOngoingCall yourself:
  • These components set their own OngoingCallListener on your builder, which replaces any listener you set. React to the call through their callbacks and events instead.
  • Without a builder, they turn on the default layout and make audio calls audio-only. Your builder is used as it is, so set enableDefaultLayout(true) and setIsAudioOnlyCall(...) yourself.

Next Steps

Incoming Call

Display and handle incoming calls

Outgoing Call

Display and manage outgoing calls

Call Buttons

Add voice and video call buttons to your UI

Call Features

Overview of all calling features