Skip to main content
This guide covers migrating from Calls SDK v4 to v5 for React Native.

Drop-in Compatibility

Calls SDK v5 is a drop-in replacement for v4. All v4 APIs are preserved as deprecated methods that internally delegate to the new v5 implementations. You can update the package version and your existing code will compile and run without changes.
npm install @cometchat/calls-sdk-react-native@5
If you’re using CometChat UI Kits, simply updating the Calls SDK version is sufficient. The UI Kit will continue to work with v5 through the deprecated compatibility layer.

Why Migrate to v5 APIs?

While v4 APIs will continue to work, migrating to v5 APIs gives you:
  • Granular event listeners — subscribe to specific events like onParticipantJoined or onSessionLeft instead of one monolithic OngoingCallListener
  • Dedicated login() method — the Calls SDK now handles its own authentication instead of depending on the Chat SDK’s auth token or REST APIs
  • Simplified initialization — pass plain objects to init() and joinSession() instead of using builder classes
  • Strongly-typed enumsLayoutType, SessionType instead of raw strings

Initialization

v5 accepts a plain object instead of requiring CallAppSettingsBuilder.
const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
  .setAppId("APP_ID")
  .setRegion("REGION")
  .build();

CometChatCalls.init(callAppSettings).then(
  () => { /* initialized */ },
  (error) => { /* handle error */ }
);
CallAppSettingsBuilder still works in v5 — it’s deprecated but functional.

Authentication

In v4, the Calls SDK had no dedicated authentication step. It relied on the Chat SDK’s auth token (CometChat.getUserAuthToken()) or a REST API to obtain an auth token, which you then passed manually to generateToken(). v5 introduces its own login() method. After calling login(), the SDK caches the auth token internally.
// No dedicated Calls SDK login — relied on Chat SDK for auth token
const authToken = CometChat.getUserAuthToken();

// Had to pass authToken manually
CometChatCalls.generateToken(sessionId, authToken).then(
  (token) => { /* use token to start session */ },
  (error) => { }
);
Call CometChatCalls.login() once after your user authenticates. The SDK stores the auth token internally, so subsequent calls like generateToken() and joinSession() use it automatically.

Session Settings

CallSettingsBuilder is replaced by passing a plain SessionSettings object directly.
const callSettings = new CometChatCalls.CallSettingsBuilder()
  .enableDefaultLayout(true)
  .setIsAudioOnlyCall(true)
  .showEndCallButton(true)
  .showMuteAudioButton(true)
  .showPauseVideoButton(true)
  .showRecordingButton(true)
  .showSwitchModeButton(true)
  .startWithAudioMuted(false)
  .startWithVideoMuted(false)
  .setMode(CometChatCalls.CALL_MODE.DEFAULT)
  .setCallListener(new CometChatCalls.OngoingCallListener({
    onCallEnded: () => { },
    onCallEndButtonPressed: () => { },
    onUserJoined: (user) => { },
    onUserLeft: (user) => { },
    onUserListUpdated: (userList) => { },
    onError: (error) => { },
  }))
  .build();

Settings Property Mapping

v4 Builder Methodv5 PropertyNotes
setIsAudioOnlyCall(true)sessionType: "VOICE"Use "VIDEO" for video calls
enableDefaultLayout(bool)hideControlPanel: !boolInverted logic
showEndCallButton(bool)hideLeaveSessionButton: !boolInverted logic
showMuteAudioButton(bool)hideToggleAudioButton: !boolInverted logic
showPauseVideoButton(bool)hideToggleVideoButton: !boolInverted logic
showRecordingButton(bool)hideRecordingButton: !boolInverted logic
showSwitchModeButton(bool)hideChangeLayoutButton: !boolInverted logic
startWithAudioMuted(bool)startAudioMuted: boolSame logic
startWithVideoMuted(bool)startVideoPaused: boolSame logic
setMode(CALL_MODE.DEFAULT)layout: "TILE"Enum instead of constant
startRecordingOnCallStart(bool)autoStartRecording: boolSame logic
setCallListener(listener)Use addEventListener()See Events section

Joining a Session

startSession() is replaced by joinSession().
CometChatCalls.generateToken(sessionId, authToken).then((token) => {
  CometChatCalls.startSession(token, callSettings);
});

Session Control (Actions)

Static methods remain on CometChatCalls but some have been renamed.
v4 Methodv5 Method
CometChatCalls.endSession()CometChatCalls.leaveSession()
CometChatCalls.switchCamera()CometChatCalls.switchCamera()
CometChatCalls.muteAudio(true)CometChatCalls.muteAudio()
CometChatCalls.muteAudio(false)CometChatCalls.unmuteAudio()
CometChatCalls.pauseVideo(true)CometChatCalls.pauseVideo()
CometChatCalls.pauseVideo(false)CometChatCalls.resumeVideo()
CometChatCalls.setMode(mode)CometChatCalls.setLayout(layout)
CometChatCalls.enterPIPMode()CometChatCalls.enablePictureInPictureLayout()
CometChatCalls.exitPIPMode()CometChatCalls.disablePictureInPictureLayout()
CometChatCalls.startRecording()CometChatCalls.startRecording()
CometChatCalls.stopRecording()CometChatCalls.stopRecording()
CometChatCalls.switchToVideoCall()Removed

Event Listeners

The single OngoingCallListener is replaced by addEventListener() with specific event types.

v4: Single Listener Object

const callSettings = new CometChatCalls.CallSettingsBuilder()
  .setCallListener(new CometChatCalls.OngoingCallListener({
    onCallEnded: () => { },
    onCallEndButtonPressed: () => { },
    onUserJoined: (user) => { },
    onUserLeft: (user) => { },
    onUserListUpdated: (userList) => { },
    onAudioModeChanged: (audioModeList) => { },
    onUserMuted: (muteInfo) => { },
    onRecordingToggled: (recordingInfo) => { },
    onError: (error) => { },
  }))
  .build();

v5: Granular Event Subscriptions

// Session events
CometChatCalls.addEventListener("onSessionJoined", () => { });
CometChatCalls.addEventListener("onSessionLeft", () => { });
CometChatCalls.addEventListener("onSessionTimedOut", () => { });
CometChatCalls.addEventListener("onConnectionLost", () => { });
CometChatCalls.addEventListener("onConnectionRestored", () => { });

// Participant events
CometChatCalls.addEventListener("onParticipantJoined", (participant) => { });
CometChatCalls.addEventListener("onParticipantLeft", (participant) => { });
CometChatCalls.addEventListener("onParticipantListChanged", (participants) => { });
CometChatCalls.addEventListener("onParticipantAudioMuted", (participant) => { });
CometChatCalls.addEventListener("onParticipantAudioUnmuted", (participant) => { });

// Media events
CometChatCalls.addEventListener("onAudioMuted", () => { });
CometChatCalls.addEventListener("onAudioUnMuted", () => { });
CometChatCalls.addEventListener("onRecordingStarted", () => { });
CometChatCalls.addEventListener("onRecordingStopped", () => { });

// Button click events
CometChatCalls.addEventListener("onLeaveSessionButtonClicked", () => { });
CometChatCalls.addEventListener("onToggleAudioButtonClicked", () => { });
CometChatCalls.addEventListener("onToggleVideoButtonClicked", () => { });

// Layout events
CometChatCalls.addEventListener("onCallLayoutChanged", (layoutType) => { });
CometChatCalls.addEventListener("onPictureInPictureLayoutEnabled", () => { });
CometChatCalls.addEventListener("onPictureInPictureLayoutDisabled", () => { });
addEventListener() returns an unsubscribe function. Call it to remove the listener.

Event Mapping

v4 Eventv5 Event
onCallEndedonSessionLeft
onCallEndButtonPressedonLeaveSessionButtonClicked
onUserJoined(user)onParticipantJoined(participant)
onUserLeft(user)onParticipantLeft(participant)
onUserListUpdated(userList)onParticipantListChanged(participants)
onAudioModeChanged(list)onAudioModeChanged(audioMode)
onUserMuted(info)onParticipantAudioMuted(participant)
onRecordingToggled(info)onRecordingStarted / onRecordingStopped
onError(error)Errors returned via Promise rejection

Deprecated Classes Summary

DeprecatedReplacement
CometChatCalls.CallAppSettingsBuilderPass plain object to init()
CometChatCalls.CallSettingsBuilderPass plain SessionSettings object to joinSession()
CometChatCalls.OngoingCallListenerCometChatCalls.addEventListener()
CometChatCalls.startSession()CometChatCalls.joinSession()
CometChatCalls.endSession()CometChatCalls.leaveSession()
RTCRecordingInfoonRecordingStarted / onRecordingStopped events
CallSwitchRequestInfoRemoved (no replacement)