Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions calls/ios/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Tabs>
<Tab title="Swift">
```swift
let callSession = CallSession.shared

Check warning on line 17 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L17

Did you really mean 'callSession'?
```
</Tab>
<Tab title="Objective-C">
Expand All @@ -25,7 +25,7 @@
</Tabs>

<Note>
Always check `isCallSessionActive()` before calling actions to ensure there's an active call.
Always check `isSessionJoined()` before calling in-call actions to ensure you are in a call.
</Note>

## Actions
Expand All @@ -42,14 +42,14 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] muteAudio];

Check warning on line 45 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L45

Did you really mean 'muteAudio'?
```
</Tab>
</Tabs>

### Unmute Audio

Check warning on line 50 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L50

Did you really mean 'Unmute'?

Unmutes your local microphone, resuming audio transmission.

Check warning on line 52 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L52

Did you really mean 'Unmutes'?

<Tabs>
<Tab title="Swift">
Expand All @@ -59,7 +59,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] unmuteAudio];

Check warning on line 62 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L62

Did you really mean 'unmuteAudio'?
```
</Tab>
</Tabs>
Expand Down Expand Up @@ -108,7 +108,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] pauseVideo];

Check warning on line 111 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L111

Did you really mean 'pauseVideo'?
```
</Tab>
</Tabs>
Expand All @@ -125,7 +125,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] resumeVideo];

Check warning on line 128 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L128

Did you really mean 'resumeVideo'?
```
</Tab>
</Tabs>
Expand All @@ -142,7 +142,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] switchCamera];

Check warning on line 145 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L145

Did you really mean 'switchCamera'?
```
</Tab>
</Tabs>
Expand All @@ -159,7 +159,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] startRecording];

Check warning on line 162 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L162

Did you really mean 'startRecording'?
```
</Tab>
</Tabs>
Expand All @@ -180,7 +180,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] stopRecording];

Check warning on line 183 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L183

Did you really mean 'stopRecording'?
```
</Tab>
</Tabs>
Expand All @@ -199,7 +199,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] startTranscription];

Check warning on line 202 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L202

Did you really mean 'startTranscription'?
```
</Tab>
</Tabs>
Expand All @@ -222,7 +222,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] stopTranscription];

Check warning on line 225 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L225

Did you really mean 'stopTranscription'?
```
</Tab>
</Tabs>
Expand All @@ -234,14 +234,14 @@
<Tabs>
<Tab title="Swift">
```swift
guard let uid = participant.uid else { return }

Check warning on line 237 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L237

Did you really mean 'uid'?

Check warning on line 237 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L237

Did you really mean 'uid'?
CallSession.shared.muteParticipant(participantId: uid)
```
</Tab>
<Tab title="Objective-C">
```objectivec
if (participant.uid) {
[[CallSession shared] muteParticipantWithParticipantId:participant.uid];

Check warning on line 244 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L244

Did you really mean 'uid'?
}
```
</Tab>
Expand All @@ -254,7 +254,7 @@
<Tabs>
<Tab title="Swift">
```swift
guard let uid = participant.uid else { return }

Check warning on line 257 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L257

Did you really mean 'uid'?
CallSession.shared.pauseParticipantVideo(participantId: uid)
```
</Tab>
Expand Down Expand Up @@ -296,7 +296,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] unpinParticipant];

Check warning on line 299 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L299

Did you really mean 'unpinParticipant'?
```
</Tab>
</Tabs>
Expand Down Expand Up @@ -383,38 +383,48 @@

### Is Session Active

Returns `true` if a call session is active, `false` otherwise.
`isSessionActive()` returns `true` while the SDK owns a session: one being prepared or prepared (for example an outgoing call that is still ringing), one being joined, or a joined one. `isSessionJoined()` is the narrower "in a call" check: `true` only once the media session is joined.

<Tabs>
<Tab title="Swift">
```swift
let isActive = CallSession.shared.isCallSessionActive()
let isActive = CallSession.shared.isSessionActive()

Check warning on line 391 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L391

Did you really mean 'isActive'?
let isInCall = CallSession.shared.isSessionJoined()
```
</Tab>
<Tab title="Objective-C">
```objectivec
BOOL isActive = [[CallSession shared] isCallSessionActive];
BOOL isActive = [[CallSession shared] isSessionActive];

Check warning on line 397 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L397

Did you really mean 'isActive'?
BOOL isInCall = [[CallSession shared] isSessionJoined];
```
</Tab>
</Tabs>

<Note>
`isCallSessionActive()` is deprecated in 5.1 and renamed `isSessionActive()`. Because it now also covers a prepared session, use `isSessionJoined()` where you meant "in a call".
</Note>

### Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.
Ends your participation and disconnects gracefully. In a 1:1 call this is the hang-up: the other side receives `onParticipantLeft` and the backend records the end, and a session joined as a peer call (`setPeerCall(true)`) ends for both. In a group call the session continues for the other participants. Leaving also cancels a session that is only prepared.

<Tabs>
<Tab title="Swift">
```swift
CallSession.shared.leaveSession()
CallSession.shared.leave()
```
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] leaveSession];
[[CallSession shared] leave];
```
</Tab>
</Tabs>

<Note>
`leaveSession()` is deprecated in 5.1 and only calls `leave()`. To end a call that is still ringing use `CometChatCalls.endCall(sessionID:status:onSuccess:onError:)` with `EndCallStatus.cancelled` (caller), as described in [Ringing](/calls/ios/ringing); `leave()` alone does not tell the other side why.
</Note>

### Raise Hand

Shows a hand-raised indicator to get attention from other participants.
Expand All @@ -427,7 +437,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] raiseHand];

Check warning on line 440 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L440

Did you really mean 'raiseHand'?
```
</Tab>
</Tabs>
Expand All @@ -444,7 +454,7 @@
</Tab>
<Tab title="Objective-C">
```objectivec
[[CallSession shared] lowerHand];

Check warning on line 457 in calls/ios/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/actions.mdx#L457

Did you really mean 'lowerHand'?
```
</Tab>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions calls/ios/custom-control-panel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Tabs>
<Tab title="Swift">
```swift
let sessionSettings = CometChatCalls.sessionSettingsBuilder

Check warning on line 39 in calls/ios/custom-control-panel.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/custom-control-panel.mdx#L39

Did you really mean 'sessionSettings'?
.hideControlPanel(true)
.build()
```
Expand Down Expand Up @@ -260,7 +260,7 @@
}

@objc private func endCall() {
CallSession.shared.leaveSession()
CallSession.shared.leave()
navigationController?.popViewController(animated: true)
}
```
Expand Down Expand Up @@ -300,7 +300,7 @@
}

- (void)endCall {
[[CallSession shared] leaveSession];
[[CallSession shared] leave];
[self.navigationController popViewControllerAnimated:YES];
}
```
Expand Down
173 changes: 162 additions & 11 deletions calls/ios/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
description: "Handle CometChat Calls SDK v5 events on iOS for call lifecycle, participants, media state, errors, and real-time updates."
---

Handle call session events to build responsive UIs. The SDK provides five event listener protocols to monitor session status, participant activities, media changes, button clicks, and layout changes.
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.

Check warning on line 8 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L8

Did you really mean 'UIs'?

## Get CallSession Instance

Expand All @@ -14,7 +14,7 @@
<Tabs>
<Tab title="Swift">
```swift
let callSession = CallSession.shared

Check warning on line 17 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L17

Did you really mean 'callSession'?
```
</Tab>
<Tab title="Objective-C">
Expand All @@ -24,8 +24,28 @@
</Tab>
</Tabs>

`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()`:

<Tabs>
<Tab title="Swift">
```swift
// nil when no session is prepared or joined
if let session = CometChatCalls.getActiveSession() {
print("Live session \(session.sessionId ?? "")")
}
```
</Tab>
<Tab title="Objective-C">
```objectivec
CallSession *session = [CometChatCalls getActiveSession]; // nil when no session is prepared or joined
```
</Tab>
</Tabs>

`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](/calls/ios/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.

Check warning on line 45 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L45

Did you really mean 'callee'?

<Note>
Remember to remove listeners when your view controller is deallocated to prevent memory leaks. Use `removeSessionStatusListener`, `removeParticipantEventListener`, etc.

Check warning on line 48 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L48

Did you really mean 'deallocated'?
</Note>

---
Expand All @@ -48,6 +68,10 @@
CallSession.shared.removeSessionStatusListener(self)
}

func onConnected() {
// A prepared session is connected (signalling only): the join will be near-instant
}

func onSessionJoined() {
// Successfully connected to the session
}
Expand All @@ -71,7 +95,8 @@
}

func onConnectionClosed() {
// Connection permanently closed
// Connection permanently closed. On a session that was only prepared
// (an outgoing call still ringing), this means the call ended before anyone joined.
navigationController?.popViewController(animated: true)
}
}
Expand All @@ -93,6 +118,10 @@
[[CallSession shared] removeSessionStatusListener:self];
}

- (void)onConnected {
// A prepared session is connected (signalling only): the join will be near-instant
}

- (void)onSessionJoined {
// Successfully connected to the session
}
Expand All @@ -116,7 +145,8 @@
}

- (void)onConnectionClosed {
// Connection permanently closed
// Connection permanently closed. On a session that was only prepared
// (an outgoing call still ringing), this means the call ended before anyone joined.
[self.navigationController popViewControllerAnimated:YES];
}

Expand All @@ -127,12 +157,13 @@

| Event | Description |
|-------|-------------|
| `onConnected()` | A prepared session connected: signalling only, no media, and other participants do not see you yet. Fires once per prepare (`initiateCall` on the caller, the Push SDK's ring on the callee); the media join is `onSessionJoined()` |

Check warning on line 160 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L160

Did you really mean 'callee'?
| `onSessionJoined()` | Successfully connected and joined the session |
| `onSessionLeft()` | Left the session via `leaveSession()` or was removed |
| `onSessionTimedOut()` | Session ended due to inactivity timeout |
| `onSessionLeft()` | Left the session via `leave()` or was removed |
| `onSessionTimedOut()` | Session ended due to inactivity timeout. Not used on a prepared session: one nobody joins within 5 minutes reports `onConnectionClosed()` |
| `onConnectionLost()` | Network interrupted, SDK attempting reconnection |
| `onConnectionRestored()` | Connection restored after being lost |
| `onConnectionClosed()` | Connection permanently closed, cannot reconnect |
| `onConnectionClosed()` | Connection permanently closed, cannot reconnect. On a prepared session: the call ended before anyone joined (declined, busy, rung out, cancelled, the room went away, or nobody joined within 5 minutes) |

---

Expand All @@ -154,8 +185,13 @@
CallSession.shared.removeParticipantEventListener(self)
}

func onParticipantConnected(participant: Participant) {
// A participant's device prepared the session but has not joined yet.
// On an outgoing call: the callee's phone is ringing.
}

func onParticipantJoined(participant: Participant) {
// A participant joined the call
// A participant joined the call. On an outgoing call: the callee answered.
}

func onParticipantLeft(participant: Participant) {
Expand Down Expand Up @@ -196,8 +232,13 @@
[[CallSession shared] removeParticipantEventListener:self];
}

- (void)onParticipantConnectedWithParticipant:(Participant *)participant {
// A participant's device prepared the session but has not joined yet.
// On an outgoing call: the callee's phone is ringing.
}

- (void)onParticipantJoinedWithParticipant:(Participant *)participant {
// A participant joined the call
// A participant joined the call. On an outgoing call: the callee answered.
}

- (void)onParticipantLeftWithParticipant:(Participant *)participant {
Expand All @@ -217,11 +258,12 @@

| Event | Parameter | Description |
|-------|-----------|-------------|
| `onParticipantJoined` | `Participant` | A participant connected to the call |
| `onParticipantConnected` | `Participant` | A remote participant's device prepared the session without joining. On the caller's prepared session this is the callee ringing |

Check warning on line 261 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L261

Did you really mean 'callee'?
| `onParticipantJoined` | `Participant` | A participant joined the call. On the caller's prepared session this is the callee answering: join now |

Check warning on line 262 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L262

Did you really mean 'callee'?
| `onParticipantLeft` | `Participant` | A participant disconnected from the call |
| `onParticipantListChanged` | `[Participant]` | Participant list updated |
| `onParticipantAudioMuted` | `Participant` | A participant muted their microphone |
| `onParticipantAudioUnmuted` | `Participant` | A participant unmuted their microphone |

Check warning on line 266 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L266

Did you really mean 'unmuted'?
| `onParticipantVideoPaused` | `Participant` | A participant turned off their camera |
| `onParticipantVideoResumed` | `Participant` | A participant turned on their camera |
| `onParticipantHandRaised` | `Participant` | A participant raised their hand |
Expand Down Expand Up @@ -344,7 +386,7 @@
| Event | Parameter | Description |
|-------|-----------|-------------|
| `onAudioMuted` | - | Your microphone was muted |
| `onAudioUnMuted` | - | Your microphone was unmuted |

Check warning on line 389 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L389

Did you really mean 'unmuted'?
| `onVideoPaused` | - | Your camera was turned off |
| `onVideoResumed` | - | Your camera was turned on |
| `onRecordingStarted` | - | Call recording started |
Expand All @@ -354,7 +396,7 @@

<Note>
`MediaEventsListener` has **no** screen-share callback. Screen sharing is observed on
[`ParticipantEventListener`](#participanteventlistener) via `onParticipantStartedScreenShare` /
[`ParticipantEventListener`](#participant-events) via `onParticipantStartedScreenShare` /
`onParticipantStoppedScreenShare` — and on iOS those are **receive-only**: the SDK reports a share
started from another client, but cannot start one locally (that needs a Broadcast Upload Extension).
</Note>
Expand Down Expand Up @@ -468,7 +510,7 @@
| `onRecordingToggleButtonClicked` | Recording toggle button was tapped |

<Note>
Button click events fire before the SDK's default action executes. Use these to add custom logic alongside default behavior.
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`.
</Note>

---
Expand Down Expand Up @@ -587,3 +629,112 @@
```
</Tab>
</Tabs>

---

## 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.

<Tabs>
<Tab title="Swift">
```swift
final class CallEvents: NSObject, CometChatIncomingCallListener {

Check warning on line 642 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L642

Did you really mean 'NSObject'?
func onIncomingCallReceived(call: CometChatIncomingCall) {
// A call for this user is ringing (CallKit already shows it)
}

func onIncomingCallEnded(call: CometChatIncomingCall, reason: String) {
// The ring ended: "cancelled", "ongoing", "unanswered", "rejected", "busy", "ended"
}
}

let callEvents = CallEvents() // held weakly by the SDK: keep this reference

Check warning on line 652 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L652

Did you really mean 'callEvents'?
CometChatCalls.addIncomingCallListener("my-screen", callEvents)

Check warning on line 653 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L653

Did you really mean 'callEvents'?

CometChatCalls.removeIncomingCallListener("my-screen")
```
</Tab>
<Tab title="Objective-C">
```objectivec
@interface CallEvents : NSObject <CometChatIncomingCallListener>
@end

@implementation CallEvents
- (void)onIncomingCallReceivedWithCall:(CometChatIncomingCall *)call {
// A call for this user is ringing (CallKit already shows it)
}
- (void)onIncomingCallEndedWithCall:(CometChatIncomingCall *)call reason:(NSString *)reason {
// The ring ended
}
@end

self.callEvents = [[CallEvents alloc] init]; // held weakly by the SDK: keep this reference
[CometChatCalls addIncomingCallListener:@"my-screen" :self.callEvents];

[CometChatCalls removeIncomingCallListener:@"my-screen"];
```
</Tab>
</Tabs>

| Event | Parameters | Description |
|-------|------------|-------------|
| `onIncomingCallReceived` | `CometChatIncomingCall` | A call for the logged-in user is ringing on this device |
| `onIncomingCallEnded` | `CometChatIncomingCall`, `reason` | The call ended before it was answered here, once per call: `cancelled` (the caller gave up), `ongoing` (answered on another device), `unanswered`, `rejected` / `busy`, or `ended` (the session prepared for it closed before the answer). Treat any other reason as "the ring is over". A decline or ring-out on this device is reported to the Push SDK delegate's `callDidEnd(_:reason:)` instead |

`CometChatIncomingCall` carries `sessionId`, `callerUid`, `callerName`, `callerAvatarUrl`, `callType`, `receiverType`, `receiverUid`, `conversationId`, `initiatedAt` (milliseconds), `isVideo` and `isPeerCall`.

<Note>
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.
</Note>

---

## 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.

Check warning on line 695 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L695

Did you really mean 'unregister'?

<Tabs>
<Tab title="Swift">
```swift
import CometChatCallsSDK

// Qualify the protocol if your app also imports the Chat SDK, which has its own CometChatLoginDelegate.
final class CallsLoginEvents: NSObject, CometChatCallsSDK.CometChatLoginDelegate {

Check warning on line 703 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L703

Did you really mean 'NSObject'?
func onLoginSuccess(user: CallsUser) {}
func onLoginFailed(error: CometChatCallException?) {}
func onLogoutSuccess() {}
func onLogoutFailed(error: CometChatCallException?) {}
}

let loginEvents = CallsLoginEvents() // held weakly by the SDK: keep this reference

Check warning on line 710 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L710

Did you really mean 'loginEvents'?
CometChatCalls.addLoginListener("my-app", loginEvents)

Check warning on line 711 in calls/ios/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/ios/events.mdx#L711

Did you really mean 'loginEvents'?

CometChatCalls.removeLoginListener("my-app")
```
</Tab>
<Tab title="Objective-C">
```objectivec
// self adopts the Calls SDK's CometChatLoginDelegate
- (void)onLoginSuccessWithUser:(CallsSDKUser *)user {}
- (void)onLoginFailedWithError:(CometChatCallException *)error {}
- (void)onLogoutSuccess {}
- (void)onLogoutFailedWithError:(CometChatCallException *)error {}

[CometChatCalls addLoginListener:@"my-app" :self];

[CometChatCalls removeLoginListener:@"my-app"];
```
</Tab>
</Tabs>

| Event | Description |
|-------|-------------|
| `onLoginSuccess(user:)` | A user logged in to the Calls SDK |
| `onLoginFailed(error:)` | A login failed |
| `onLogoutSuccess()` | The user logged out |
| `onLogoutFailed(error:)` | A logout failed |

<Note>
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.
</Note>
Loading
Loading