Skip to main content
Handle call session events to build responsive UIs. The SDK provides five session listener protocols to monitor session status, participant activities, media changes, button clicks, and layout changes, plus two global listeners for incoming calls and login state. The SDK holds every listener weakly and removes none of them for you, so keep a strong reference to each listener object and remove it when your screen goes away.

Get CallSession Instance

The CallSession is a singleton that manages the active call. All event listener registrations and session control methods are accessed through this instance.
CallSession.shared always exists, so listeners registered on it work before any session does. To ask whether there is a session right now, use CometChatCalls.getActiveSession():
getActiveSession() returns CallSession.shared as soon as a session is prepared, which is what CometChatCalls.initiateCall does on the caller and what the Push SDK’s ring does on the callee, before anyone joins. That is what lets a caller listen for “ringing” and “answered” without joining (see Ringing). Before a session is prepared or joined it returns nil, so code that registers through it (getActiveSession()?.addSessionStatusListener(self)) registers nothing; register on CallSession.shared instead.
CallSession holds listeners weakly. It does not keep your listener alive, so the object you register must be owned elsewhere, such as the view controller itself (as in the examples below) or a stored property. A listener created inline, like addSessionStatusListener(MyListener()), is deallocated right away and never receives an event. A deallocated listener is dropped automatically. Call removeSessionStatusListener, removeParticipantEventListener, etc. when you want events to stop before the listener goes away.

Session Events

Monitor the call session lifecycle including join/leave events and connection status.

Participant Events

Monitor participant activities including join/leave, audio/video state, hand raise, screen sharing, and recording.

Media Events

Monitor your local media state changes including audio/video status, recording, and device changes.
MediaEventsListener has no screen-share callback. Screen sharing is observed on ParticipantEventListener via onParticipantStartedScreenShare / onParticipantStoppedScreenShare — and on iOS those are receive-only: the SDK reports a share started from another client, but has no API to start one locally.

Button Click Events

Intercept UI button clicks from the default call interface to add custom behavior or analytics.
Button click events fire before the SDK’s default action executes. Use these to add custom logic alongside default behavior. The Leave button is the exception: the SDK leaves the session itself when it is tapped, so only clean up in onLeaveSessionButtonClicked.

Layout Events

Monitor layout changes including layout type switches and Picture-in-Picture mode transitions.

Clear All Listeners

Remove all registered listeners at once. Useful when cleaning up resources.

Incoming Call Events

CometChatCalls.addIncomingCallListener is a global listener, not tied to a session. It reports a call ringing on this device and the end of that ring, whether the call arrived by VoIP push while the app was killed or while it was running. The Push Notifications SDK feeds it; it reports incoming calls only, not the end of your own outgoing call.
CometChatIncomingCall carries sessionId, callerUid, callerName, callerAvatarUrl, callType, receiverType, receiverUid, conversationId, initiatedAt (milliseconds), isVideo and isPeerCall.
Listener ids are keys: registering the same id twice replaces the earlier listener. Do not use the id cometchat-push-notifications, which the Push SDK registers under.

Login Events

CometChatCalls.addLoginListener reports the Calls SDK login state. The Push SDK uses it to register and unregister the push tokens and to stop a ring when the user logs out; your app can use it to gate call UI.
Login listener ids are keys too: registering the same id twice replaces the earlier listener. Do not use the id cometchat-push-notifications-calls, which the Push SDK registers under.