> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-ios-ui-kit-sdk-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# All Real Time Delegates (Listeners)

> Complete reference for all CometChat iOS SDK real-time delegates including User, Group, Message, and Call listeners.

<Info>
  **Quick Reference for AI Agents & Developers**

  * **User delegate:** `CometChat.userdelegate = self` (conform to `CometChatUserDelegate`) — `onUserOnline(user:)`, `onUserOffline(user:)`
  * **Group delegate:** `CometChat.groupdelegate = self` (conform to `CometChatGroupDelegate`) — member joined/left/kicked/banned events
  * **Message delegate:** `CometChat.messagedelegate = self` (conform to `CometChatMessageDelegate`) — message received/edited/deleted/reaction events
  * **Call delegate:** `CometChat.calldelegate = self` (conform to `CometChatCallDelegate`) — incoming/outgoing call events
  * **Login delegate:** `CometChat.addLoginListener(_:_:)` (conform to `CometChatLoginDelegate`) — login/logout success/failure events
  * **Connection delegate:** `CometChat.addConnectionListener(_:_:)` (conform to `CometChatConnectionDelegate`) — connection status events
  * **AI Assistant delegate:** `CometChat.addAIAssistantListener(_:_:)` (conform to `AIAssistantEventsDelegate`) — AI events
  * **Related:** [User Presence](/sdk/ios/user-presence) · [Receive Message](/sdk/ios/receive-message) · [Ringing](/sdk/ios/default-calling)
</Info>

CometChat provides 4 listeners (Delegates) viz.

1. [User Delegate (Listener)](/sdk/ios/all-real-time-delegates-listeners#user-delegate-methods)
2. [Group Delegate (Listener)](/sdk/ios/all-real-time-delegates-listeners#group-delegate-methods)
3. [Message Delegate (Listener)](/sdk/ios/all-real-time-delegates-listeners#message-delegate-methods)
4. [Call Delegate (Listener)](/sdk/ios/all-real-time-delegates-listeners#call-delegate-methods)

***

## User Delegate Methods

The `CometChat` provides you with live events related to users. Below are the callback methods provided by the `CometChatUserDelegate`.

| Delegate Method                | Information                                                                                                                                                                |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **onUserOnline(user: User)**   | This method is triggered when a user comes online and is available to chat. The details of the user can be obtained from the user object received as the method parameter. |
| **onUserOffline(user: User)**: | This method is triggered when a user goes offline. The details of the user can be obtained from the User object received as the parameter.                                 |

In order to use the Delegate methods you must add protocol conformance `CometChatUserDelegate` as Shown Below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController : CometChatUserDelegate {

        func onUserOnline(user: User) {
          print(user.stringValue() + " status becomes online.")
        }

        func onUserOffline(user: User) {
          print(user.stringValue() + " status becomes offline.")
        }
    }
    ```
  </Tab>

  <Tab title="Objective C">
    ```objc theme={null}
    @interface ViewController ()<CometChatUserDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {
        [super viewDidLoad];

        [CometChat setUserdelegate:self];
    }

    - (void)onUserOfflineWithUser:(User * _Nonnull)user {
        NSLog(@"%@ status becomes offline.",[user stringValue]);
    }

    - (void)onUserOnlineWithUser:(User * _Nonnull)user {

        NSLog(@"%@ status becomes online.",[user stringValue]);
    }
    ```
  </Tab>
</Tabs>

<Warning>
  **Do not forget to set your view controller as a CometChat delegate probably in `viewDidLoad()` as `CometChat.userdelegate = self`**
</Warning>

<Accordion title="Sample Payload - onUserOnline Event">
  **Event Trigger:** Received via `CometChatUserDelegate.onUserOnline(user:)`

  **user ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter    | Type                                                  | Description                                                                                                |
  | ------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
  | uid          | String?                                               | Unique identifier of the user. Example: `"cometchat-uid-2"`                                                |
  | name         | String?                                               | Display name of the user. Example: `"George Alan"`                                                         |
  | avatar       | String?                                               | URL to the user's avatar. Example: `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | status       | [UserStatus](/sdk/ios/users-overview#userstatus-enum) | User's current status. Example: `.online`                                                                  |
  | lastActiveAt | Double?                                               | Unix timestamp of last activity. Example: `1699800000`                                                     |
</Accordion>

<Accordion title="Sample Payload - onUserOffline Event">
  **Event Trigger:** Received via `CometChatUserDelegate.onUserOffline(user:)`

  **user ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter    | Type                                                  | Description                                                                                                |
  | ------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
  | uid          | String?                                               | Unique identifier of the user. Example: `"cometchat-uid-2"`                                                |
  | name         | String?                                               | Display name of the user. Example: `"George Alan"`                                                         |
  | avatar       | String?                                               | URL to the user's avatar. Example: `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | status       | [UserStatus](/sdk/ios/users-overview#userstatus-enum) | User's current status. Example: `.offline`                                                                 |
  | lastActiveAt | Double?                                               | Unix timestamp of last activity. Example: `1699800100`                                                     |
</Accordion>

***

## Group Delegate Methods

The `CometChatGroupDelegate` provides you with all the real-time events related to groups. Below are the callback methods provided by the `CometChatGroupDelegate`.

| Method                                                                                                                                            | Information                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| **onGroupMemberJoined(action: Action, joinedUser: User, joinedGroup: Group)**                                                                     | This method is triggered when a user joins any group. All the members present in the group will receive this event.                            |
| **onGroupMemberLeft(action: Action, leftUser: User, leftGroup: Group)**                                                                           | This method is triggered when a user who was a member of any group leaves the group. All the members of the group receive this event.          |
| **onGroupMemberKicked(action: Action, kickedUser: User, kickedBy: User, kickedFrom: Group)**                                                      | This method is triggered when a user is kicked from a group. All the members including the user receive this event                             |
| **onGroupMemberBanned(action: Action, bannedUser: User, bannedBy: User, bannedFrom: Group)**                                                      | This method is triggered when a user is banned from a group. All the members including the user receive this event                             |
| **onGroupMemberUnbanned(action: Action, unbannedUser: User, unbannedBy: User, unbannedFrom: Group)**                                              | This method is triggered when a user is banned from a group. All the members of the group receive this event.                                  |
| **onGroupMemberScopeChanged(action: Action, updatedBy: User, updatedUser: User, scopeChangedTo: String, scopeChangedFrom: String, group: Group)** | This method is triggered when the scope of any Group Member has been changed. All the members that are a part of that group receive this event |
| **onMemberAddedToGroup(action: Action, addedby: User, userAdded: User, addedTo: Group)**                                                          | This method is triggered when a user is added to any group. All the members including the user himself receive this event.                     |

You can receive live events related to groups, In order to receive user Events, you must add protocol conformance `CometChatGroupDelegate` as shown below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension AppDelegate: CometChatGroupDelegate {

      func onGroupMemberJoined(action: ActionMessage, joinedUser: User, joinedGroup: Group) {
        print("\(joinedUser.name) joined the group \(joinedGroup.name).")
      }

      func onGroupMemberLeft(action: ActionMessage, leftUser: User, leftGroup: Group) {
        print("\(leftUser.name) left the group \(leftGroup.name).")
      }

      func onGroupMemberKicked(action: ActionMessage, kickedUser: User, kickedBy: User, kickedFrom: Group) {
        print("\(kickedUser.name) kicked from the group \(kickedFrom.name) by \(kickedBy.name).")
      }

      func onGroupMemberBanned(action: ActionMessage, bannedUser: User, bannedBy: User, bannedFrom: Group) {
        print("\(bannedUser.name) banned from the group \(bannedFrom.name) by \(bannedBy.name).")
      }

      func onGroupMemberUnbanned(action: ActionMessage, unbannedUser: User, unbannedBy: User, unbannedFrom: Group) {
        print("\(unbannedUser.name) unbanned from the group \(unbannedFrom.name) by \(unbannedBy.name).")
      }

      func onGroupMemberScopeChanged(action: ActionMessage, scopeChangeduser: User, scopeChangedBy: User, scopeChangedTo: String, scopeChangedFrom: String, group: Group) {
        print("\(scopeChangedUser.name) scope changed from \(scopeChangedFrom) to \(scopeChangedTo) by \(scopeChangedBy.name) in the group \(group.name).")
      }
    }
    ```
  </Tab>

  <Tab title="Objective C">
    ```objc theme={null}
    @interface ViewController ()<CometChatGroupDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {
      [super viewDidLoad];
      [CometChat setGroupdelegate:self];
    }

    - (void)onGroupMemberBannedWithAction:(Action *)action bannedUser:(User * _Nonnull)bannedUser bannedBy:(User * _Nonnull)bannedBy bannedFrom:(Group * _Nonnull)bannedFrom {
      NSLog(@"Group member banned.");
    }

    - (void)onGroupMemberJoinedWithAction:(Action *)action joinedUser:(User * _Nonnull)joinedUser joinedGroup:(Group * _Nonnull)joinedGroup {
      NSLog(@"Group member joined.");
    }

    - (void)onGroupMemberKickedWithAction:(Action *)action kickedUser:(User * _Nonnull)kickedUser kickedBy:(User * _Nonnull)kickedBy kickedFrom:(Group * _Nonnull)kickedFrom {
      NSLog(@"Group member kicked.");
    }

    - (void)onGroupMemberLeftWithAction:(ActionMessage *)action leftUser:(User *)leftUser leftGroup:(Group *)leftGroup {
      NSLog(@"Group member left.");
    }

    - (void)onGroupMemberScopeChangedWithAction:(Action *)action user:(User * _Nonnull)user scopeChangedTo:(NSString * _Nonnull)scopeChangedTo scopeChangedFrom:(NSString * _Nonnull)scopeChangedFrom group:(Group * _Nonnull)group {
      NSLog(@"Group member scope changed.");
    }

    - (void)onGroupMemberUnbannedWithAction:(Action *)action unbannedUser:(User * _Nonnull)unbannedUser unbannedBy:(User * _Nonnull)unbannedBy unbannedFrom:(Group * _Nonnull)unbannedFrom {
      NSLog(@"Group member unbanned.");
    }

    @end
    ```
  </Tab>
</Tabs>

<Warning>
  **Do not forget to set your view controller as a CometChat delegate probably in `viewDidLoad()` as `CometChat.groupdelegate = self`**
</Warning>

<Accordion title="Sample Payload - onGroupMemberJoined Event">
  **Event Trigger:** Received via `CometChatGroupDelegate.onGroupMemberJoined(action:joinedUser:joinedGroup:)`

  **action (ActionMessage Object):**

  | Parameter | Type   | Description                      |
  | --------- | ------ | -------------------------------- |
  | action    | String | Action type. Example: `"joined"` |

  **joinedUser ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                              |
  | --------- | ------- | -------------------------------------------------------- |
  | uid       | String? | UID of the user who joined. Example: `"cometchat-uid-3"` |
  | name      | String? | Display name. Example: `"Nancy Grace"`                   |

  **joinedGroup ([Group](/sdk/ios/retrieve-groups#group-properties) Object):**

  | Parameter    | Type    | Description                                     |
  | ------------ | ------- | ----------------------------------------------- |
  | guid         | String  | Group identifier. Example: `"cometchat-guid-1"` |
  | name         | String? | Group name. Example: `"My Group"`               |
  | membersCount | Int     | Updated member count. Example: `6`              |
</Accordion>

<Accordion title="Sample Payload - onGroupMemberLeft Event">
  **Event Trigger:** Received via `CometChatGroupDelegate.onGroupMemberLeft(action:leftUser:leftGroup:)`

  **leftUser ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                            |
  | --------- | ------- | ------------------------------------------------------ |
  | uid       | String? | UID of the user who left. Example: `"cometchat-uid-3"` |
  | name      | String? | Display name. Example: `"Nancy Grace"`                 |

  **leftGroup ([Group](/sdk/ios/retrieve-groups#group-properties) Object):**

  | Parameter    | Type    | Description                                     |
  | ------------ | ------- | ----------------------------------------------- |
  | guid         | String  | Group identifier. Example: `"cometchat-guid-1"` |
  | name         | String? | Group name. Example: `"My Group"`               |
  | membersCount | Int     | Updated member count. Example: `4`              |
</Accordion>

<Accordion title="Sample Payload - onGroupMemberKicked Event">
  **Event Trigger:** Received via `CometChatGroupDelegate.onGroupMemberKicked(action:kickedUser:kickedBy:kickedFrom:)`

  **kickedUser ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                          |
  | --------- | ------- | ---------------------------------------------------- |
  | uid       | String? | UID of the kicked user. Example: `"cometchat-uid-3"` |
  | name      | String? | Display name. Example: `"Nancy Grace"`               |

  **kickedBy ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                               |
  | --------- | ------- | --------------------------------------------------------- |
  | uid       | String? | UID of the admin who kicked. Example: `"cometchat-uid-1"` |
  | name      | String? | Display name. Example: `"Andrew Joseph"`                  |

  **kickedFrom ([Group](/sdk/ios/retrieve-groups#group-properties) Object):**

  | Parameter | Type    | Description                                     |
  | --------- | ------- | ----------------------------------------------- |
  | guid      | String  | Group identifier. Example: `"cometchat-guid-1"` |
  | name      | String? | Group name. Example: `"My Group"`               |
</Accordion>

<Accordion title="Sample Payload - onGroupMemberBanned Event">
  **Event Trigger:** Received via `CometChatGroupDelegate.onGroupMemberBanned(action:bannedUser:bannedBy:bannedFrom:)`

  **bannedUser ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                          |
  | --------- | ------- | ---------------------------------------------------- |
  | uid       | String? | UID of the banned user. Example: `"cometchat-uid-3"` |
  | name      | String? | Display name. Example: `"Nancy Grace"`               |

  **bannedBy ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                               |
  | --------- | ------- | --------------------------------------------------------- |
  | uid       | String? | UID of the admin who banned. Example: `"cometchat-uid-1"` |
  | name      | String? | Display name. Example: `"Andrew Joseph"`                  |

  **bannedFrom ([Group](/sdk/ios/retrieve-groups#group-properties) Object):**

  | Parameter | Type    | Description                                     |
  | --------- | ------- | ----------------------------------------------- |
  | guid      | String  | Group identifier. Example: `"cometchat-guid-1"` |
  | name      | String? | Group name. Example: `"My Group"`               |
</Accordion>

<Accordion title="Sample Payload - onGroupMemberScopeChanged Event">
  **Event Trigger:** Received via `CometChatGroupDelegate.onGroupMemberScopeChanged(action:scopeChangeduser:scopeChangedBy:scopeChangedTo:scopeChangedFrom:group:)`

  **scopeChangeduser ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                                       |
  | --------- | ------- | ----------------------------------------------------------------- |
  | uid       | String? | UID of the user whose scope changed. Example: `"cometchat-uid-2"` |
  | name      | String? | Display name. Example: `"George Alan"`                            |

  **scopeChangedBy ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type    | Description                                                      |
  | --------- | ------- | ---------------------------------------------------------------- |
  | uid       | String? | UID of the admin who changed scope. Example: `"cometchat-uid-1"` |
  | name      | String? | Display name. Example: `"Andrew Joseph"`                         |

  **Scope Change Details:**

  | Parameter        | Type   | Description                              |
  | ---------------- | ------ | ---------------------------------------- |
  | scopeChangedTo   | String | New scope. Example: `"admin"`            |
  | scopeChangedFrom | String | Previous scope. Example: `"participant"` |

  **group ([Group](/sdk/ios/retrieve-groups#group-properties) Object):**

  | Parameter | Type    | Description                                     |
  | --------- | ------- | ----------------------------------------------- |
  | guid      | String  | Group identifier. Example: `"cometchat-guid-1"` |
  | name      | String? | Group name. Example: `"My Group"`               |
</Accordion>

***

## Message Delegate Methods

The `CometChatMessageDelegate` provides you with live events related to messages. Below are the callback methods provided by the `CometChatMessageDelegate`.

| **Method**                                                                                                           | Information                                                                                             |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| **onTextMessageReceived(textMessage: TextMessage)**                                                                  | This event is triggered when a Text Message is received.                                                |
| **onMediaMessageReceived(mediaMessage: MediaMessage)**                                                               | This event is triggered when a Media Message is received.                                               |
| **onCustomMessageReceived(customMessage: CustomMessage)**                                                            | This event is triggered when a Custom Message is received.                                              |
| **onTypingStarted(\_ typingDetails: TypingIndicator)**                                                               | This event is triggered when a user starts typing in a user/group conversation.                         |
| **onTypingEnded(\_ typingDetails: TypingIndicator)**                                                                 | This event is triggered when a user stops typing in a user/group conversation.                          |
| **onTransisentMessageReceived(\_ message: TransientMessage)**                                                        | This event is triggered when a transient message is received.                                           |
| **onMessagesDelivered(receipt: MessageReceipt)**                                                                     | This event is triggered when a set of messages are marked as delivered for any particular conversation. |
| **onMessagesRead(receipt: MessageReceipt)**                                                                          | This event is triggered when a set of messages are marked as read for any particular conversation.      |
| **onMessagesDeliveredToAll(receipt: MessageReceipt)**                                                                | This event is triggered when messages are delivered to all participants in a group.                     |
| **onMessagesReadByAll(receipt: MessageReceipt)**                                                                     | This event is triggered when messages are read by all participants in a group.                          |
| **onMessageEdited(message: BaseMessage)**                                                                            | This method is triggered when a particular message has been edited in a user/group conversation.        |
| **onMessageDeleted(message: BaseMessage)**                                                                           | This event is triggered when a particular message is deleted in a user/group conversation.              |
| **onInteractiveMessageReceived(interactiveMessage: InteractiveMessage)**                                             | This event is triggered when an Interactive Message is received.                                        |
| **onInteractionGoalCompleted(\_ receipt: InteractionReceipt)**                                                       | This event is triggered when an interaction Goal is achieved.                                           |
| **onMessageReactionAdded(reactionEvent: ReactionEvent)**                                                             | This event is triggered when a reaction is added to a message.                                          |
| **onMessageReactionRemoved(reactionEvent: ReactionEvent)**                                                           | This event is triggered when a reaction is removed from a message.                                      |
| **onMessageModerated(\_ message: BaseMessage)**                                                                      | This event is triggered when a message is moderated.                                                    |
| **onAIAssistantMessageReceived(\_ message: AIAssistantMessage)**                                                     | This event is triggered when an AI Assistant message is received.                                       |
| **onAIToolResultMessageReceived(\_ message: AIToolResultMessage)**                                                   | This event is triggered when an AI Tool result message is received.                                     |
| **onAIToolArgumentsMessageReceived(\_ message: AIToolArgumentMessage)**                                              | This event is triggered when an AI Tool arguments message is received.                                  |
| In order to receive incoming messages, you must add protocol conformance `CometChatMessageDelegate` as Shown Below : |                                                                                                         |

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: CometChatMessageDelegate {

      func onTextMessageReceived(textMessage: TextMessage) {
        print("TextMessage received successfully.")
      }

      func onMediaMessageReceived(mediaMessage: MediaMessage) {
        print("MediaMessage received successfully.")
      }

      func onCustomMessageReceived(customMessage: CustomMessage) {
        print("CustomMessage received successfully.")
      }

      func onMessageEdited(message: BaseMessage) {
        print("Message edited successfully.")
      }

      func onMessageDeleted(message: BaseMessage) {
        print("Message deleted successfully.")
      }

      func onTypingStarted(_ typingDetails: TypingIndicator) {
        print("Typing started received successfully")
      }

      func onTypingEnded(_ typingDetails: TypingIndicator) {
        print("Typing ended received successfully")
      }

      func onTransisentMessageReceived(_ message: TransientMessage) {
        print("Transient message received.")
      }

      func onMessagesDelivered(receipt: MessageReceipt) {
        print("Messages delivered receipt received.")
      }

      func onMessagesRead(receipt: MessageReceipt) {
        print("Messages read receipt received.")
      }

      func onMessagesDeliveredToAll(receipt: MessageReceipt) {
        print("Messages delivered to all receipt received.")
      }

      func onMessagesReadByAll(receipt: MessageReceipt) {
        print("Messages read by all receipt received.")
      }

      func onInteractiveMessageReceived(interactiveMessage: InteractiveMessage) {
        print("InteractiveMessage received successfully.")
      }

      func onInteractionGoalCompleted(_ receipt: InteractionReceipt) {
        print("Interaction goal completed.")
      }

      func onMessageReactionAdded(reactionEvent: ReactionEvent) {
        print("Reaction added to message.")
      }

      func onMessageReactionRemoved(reactionEvent: ReactionEvent) {
        print("Reaction removed from message.")
      }

      func onMessageModerated(_ message: BaseMessage) {
        print("Message moderated.")
      }

      func onAIAssistantMessageReceived(_ message: AIAssistantMessage) {
        print("AI Assistant message received.")
      }

      func onAIToolResultMessageReceived(_ message: AIToolResultMessage) {
        print("AI Tool result message received.")
      }

      func onAIToolArgumentsMessageReceived(_ message: AIToolArgumentMessage) {
        print("AI Tool arguments message received.")
      }
    }
    ```
  </Tab>
</Tabs>

<Warning>
  **Do not forget to set your view controller as a CometChat delegate probably in `viewDidLoad()` as `CometChat.messagedelegate = self`**
</Warning>

<Accordion title="Sample Payload - onTextMessageReceived Event">
  **Event Trigger:** Received via `CometChatMessageDelegate.onTextMessageReceived(textMessage:)`

  **textMessage (TextMessage Object):**

  | Parameter    | Type                                            | Description                                                                  |
  | ------------ | ----------------------------------------------- | ---------------------------------------------------------------------------- |
  | id           | Int                                             | Unique message identifier. Example: `12345`                                  |
  | text         | String                                          | Message content. Example: `"Hello, how are you?"`                            |
  | sender       | [User](/sdk/ios/users-overview#user-properties) | Sender details. Example: `{"uid": "cometchat-uid-2", "name": "George Alan"}` |
  | receiverUid  | String?                                         | Receiver UID (for user messages). Example: `"cometchat-uid-1"`               |
  | receiverType | ReceiverType                                    | Type of receiver. Example: `.user` or `.group`                               |
  | sentAt       | Double                                          | Unix timestamp when sent. Example: `1699800000`                              |
  | deliveredAt  | Double?                                         | Unix timestamp when delivered. Example: `1699800001`                         |
  | readAt       | Double?                                         | Unix timestamp when read. Example: `nil`                                     |
</Accordion>

<Accordion title="Sample Payload - onMediaMessageReceived Event">
  **Event Trigger:** Received via `CometChatMessageDelegate.onMediaMessageReceived(mediaMessage:)`

  **mediaMessage (MediaMessage Object):**

  | Parameter                | Type                                            | Description                                     |
  | ------------------------ | ----------------------------------------------- | ----------------------------------------------- |
  | id                       | Int                                             | Unique message identifier. Example: `12346`     |
  | attachment               | Attachment                                      | Media attachment details                        |
  | attachment.fileUrl       | String                                          | URL to the media file. Example: `"https://..."` |
  | attachment.fileName      | String                                          | File name. Example: `"image.png"`               |
  | attachment.fileExtension | String                                          | File extension. Example: `"png"`                |
  | attachment.fileMimeType  | String                                          | MIME type. Example: `"image/png"`               |
  | attachment.fileSize      | Int                                             | File size in bytes. Example: `102400`           |
  | sender                   | [User](/sdk/ios/users-overview#user-properties) | Sender details                                  |
  | sentAt                   | Double                                          | Unix timestamp when sent. Example: `1699800000` |
</Accordion>

<Accordion title="Sample Payload - onTypingStarted/onTypingEnded Events">
  **Event Trigger:** Received via `CometChatMessageDelegate.onTypingStarted(_:)` or `onTypingEnded(_:)`

  **typingDetails (TypingIndicator Object):**

  | Parameter    | Type                                            | Description                                                                      |
  | ------------ | ----------------------------------------------- | -------------------------------------------------------------------------------- |
  | sender       | [User](/sdk/ios/users-overview#user-properties) | User who is typing. Example: `{"uid": "cometchat-uid-2", "name": "George Alan"}` |
  | receiverId   | String                                          | Receiver UID or GUID. Example: `"cometchat-uid-1"`                               |
  | receiverType | ReceiverType                                    | Type of receiver. Example: `.user` or `.group`                                   |
</Accordion>

<Accordion title="Sample Payload - onMessagesDelivered/onMessagesRead Events">
  **Event Trigger:** Received via `CometChatMessageDelegate.onMessagesDelivered(receipt:)` or `onMessagesRead(receipt:)`

  **receipt (MessageReceipt Object):**

  | Parameter    | Type                                            | Description                                                      |
  | ------------ | ----------------------------------------------- | ---------------------------------------------------------------- |
  | messageId    | Int                                             | ID of the message. Example: `12345`                              |
  | sender       | [User](/sdk/ios/users-overview#user-properties) | User who sent the receipt. Example: `{"uid": "cometchat-uid-2"}` |
  | receiverId   | String                                          | Receiver UID or GUID. Example: `"cometchat-uid-1"`               |
  | receiverType | ReceiverType                                    | Type of receiver. Example: `.user`                               |
  | receiptType  | ReceiptType                                     | Type of receipt. Example: `.delivered` or `.read`                |
  | timestamp    | Double                                          | Unix timestamp. Example: `1699800100`                            |
</Accordion>

<Accordion title="Sample Payload - onMessageReactionAdded/Removed Events">
  **Event Trigger:** Received via `CometChatMessageDelegate.onMessageReactionAdded(reactionEvent:)` or `onMessageReactionRemoved(reactionEvent:)`

  **reactionEvent (ReactionEvent Object):**

  | Parameter    | Type                                            | Description                                                                    |
  | ------------ | ----------------------------------------------- | ------------------------------------------------------------------------------ |
  | reaction     | String                                          | Emoji reaction. Example: `"👍"`                                                |
  | messageId    | Int                                             | ID of the message. Example: `12345`                                            |
  | reactedBy    | [User](/sdk/ios/users-overview#user-properties) | User who reacted. Example: `{"uid": "cometchat-uid-2", "name": "George Alan"}` |
  | receiverId   | String                                          | Receiver UID or GUID. Example: `"cometchat-uid-1"`                             |
  | receiverType | ReceiverType                                    | Type of receiver. Example: `.user`                                             |
</Accordion>

***

## Call Delegate Methods

The `CometChatCallDelegate` provides you with live events related to calls. Below are the callback methods provided by the `CometChatCallDelegate`.

| Method                                                                       | Information                                                                                                                                                                                        |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **onIncomingCallReceived(incomingCall: Call?, error: CometChatException?)**  | This event is triggered when the logged-in user receives an incoming call. The details of the call can be obtained from the Call object received as the method parameter.                          |
| **onOutgoingCallAccepted(acceptedCall: Call?, error: CometChatException?)**  | This event is triggered when the call initiated by the logged-in user is accepted by the recipient. The details of the call can be obtained from the Call object received as the method parameter. |
| **onOutgoingCallRejected(rejectedCall: Call?, error: CometChatException?)**  | This event is triggered when the call initiated by the logged-in user is rejected by the recipient. The details of the call can be obtained from the Call object received as the method parameter  |
| **onIncomingCallCancelled(canceledCall: Call?, error: CometChatException?)** | This event is triggered when an incoming call is canceled by the initiator of the call. The details of the call can be obtained from the Call object received as the method parameter              |
| **onCallEndedMessageReceived(endedCall: Call?, error: CometChatException?)** | This event is triggered when a call ended message is received. The details of the call can be obtained from the Call object received as the method parameter                                       |

In order to receive all `call` events, you must add protocol conformance `CometChatCallDelegate` as Shown Below :

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: CometChatCallDelegate {

      func onIncomingCallReceived(incomingCall: Call?, error: CometChatException?) {
        print("Incoming call " + (incomingCall?.stringValue() ?? ""))
      }

      func onOutgoingCallAccepted(acceptedCall: Call?, error: CometChatException?) {
        print("Outgoing call accepted " + (acceptedCall?.stringValue() ?? ""))
      }

      func onOutgoingCallRejected(rejectedCall: Call?, error: CometChatException?) {
        print("Rejected call " + (rejectedCall?.stringValue() ?? ""))
      }

      func onIncomingCallCancelled(canceledCall: Call?, error: CometChatException?) {
        print("Cancelled call " + (canceledCall?.stringValue() ?? ""))
      }

      func onCallEndedMessageReceived(endedCall: Call?, error: CometChatException?) {
        print("Call ended " + (endedCall?.stringValue() ?? ""))
      }
    }
    ```
  </Tab>

  <Tab title="Objective C">
    ```objc theme={null}
    @interface ViewController ()<CometChatCallDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {
      [super viewDidLoad];
      [CometChat setCalldelegate:self];
    }

    - (void)onIncomingCallCancelledWithCanceledCall:(Call * _Nullable)canceledCall error:(CometChatException * _Nullable)error {
      NSLog(@"Incoming call cancelled %@",[canceledCall stringValue]);
    }

    - (void)onIncomingCallReceivedWithIncomingCall:(Call * _Nullable)incomingCall error:(CometChatException * _Nullable)error {
      NSLog(@"Incoming call %@",[incomingCall stringValue]);
    }

    - (void)onOutgoingCallAcceptedWithAcceptedCall:(Call * _Nullable)acceptedCall error:(CometChatException * _Nullable)error {
      NSLog(@"Outgoing call accepted %@",[acceptedCall stringValue]);
    }

    - (void)onOutgoingCallRejectedWithRejectedCall:(Call * _Nullable)rejectedCall error:(CometChatException * _Nullable)error {
      NSLog(@"Outgoing call rejected %@",[rejectedCall stringValue]);
    }

    - (void)onCallEndedMessageReceivedWithEndedCall:(Call * _Nullable)endedCall error:(CometChatException * _Nullable)error {
      NSLog(@"Call ended %@",[endedCall stringValue]);
    }

    @end
    ```
  </Tab>
</Tabs>

<Warning>
  **Do not forget to set your view controller as a CometChat delegate probably in `viewDidLoad()` as `CometChat.calldelegate = self`**
</Warning>

<Accordion title="Sample Payload - onIncomingCallReceived Event">
  **Event Trigger:** Received via `CometChatCallDelegate.onIncomingCallReceived(incomingCall:error:)`

  **incomingCall (Call Object):**

  | Parameter     | Type                                            | Description                                                                               |
  | ------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------- |
  | sessionId     | String                                          | Unique call session ID. Example: `"v1.us.12345.abcdef"`                                   |
  | callInitiator | [User](/sdk/ios/users-overview#user-properties) | User who initiated the call. Example: `{"uid": "cometchat-uid-2", "name": "George Alan"}` |
  | callReceiver  | [User](/sdk/ios/users-overview#user-properties) | User receiving the call. Example: `{"uid": "cometchat-uid-1", "name": "Andrew Joseph"}`   |
  | callType      | CallType                                        | Type of call. Example: `.audio` or `.video`                                               |
  | callStatus    | CallStatus                                      | Current call status. Example: `.initiated`                                                |
  | initiatedAt   | Double                                          | Unix timestamp when initiated. Example: `1699800000`                                      |
</Accordion>

<Accordion title="Sample Payload - onOutgoingCallAccepted Event">
  **Event Trigger:** Received via `CometChatCallDelegate.onOutgoingCallAccepted(acceptedCall:error:)`

  **acceptedCall (Call Object):**

  | Parameter     | Type                                            | Description                                                        |
  | ------------- | ----------------------------------------------- | ------------------------------------------------------------------ |
  | sessionId     | String                                          | Unique call session ID. Example: `"v1.us.12345.abcdef"`            |
  | callInitiator | [User](/sdk/ios/users-overview#user-properties) | User who initiated the call. Example: `{"uid": "cometchat-uid-1"}` |
  | callReceiver  | [User](/sdk/ios/users-overview#user-properties) | User who accepted. Example: `{"uid": "cometchat-uid-2"}`           |
  | callType      | CallType                                        | Type of call. Example: `.video`                                    |
  | callStatus    | CallStatus                                      | Current call status. Example: `.ongoing`                           |
</Accordion>

<Accordion title="Sample Payload - onOutgoingCallRejected Event">
  **Event Trigger:** Received via `CometChatCallDelegate.onOutgoingCallRejected(rejectedCall:error:)`

  **rejectedCall (Call Object):**

  | Parameter     | Type                                            | Description                                                        |
  | ------------- | ----------------------------------------------- | ------------------------------------------------------------------ |
  | sessionId     | String                                          | Unique call session ID. Example: `"v1.us.12345.abcdef"`            |
  | callInitiator | [User](/sdk/ios/users-overview#user-properties) | User who initiated the call. Example: `{"uid": "cometchat-uid-1"}` |
  | callReceiver  | [User](/sdk/ios/users-overview#user-properties) | User who rejected. Example: `{"uid": "cometchat-uid-2"}`           |
  | callStatus    | CallStatus                                      | Current call status. Example: `.rejected`                          |
</Accordion>

<Accordion title="Sample Payload - onCallEndedMessageReceived Event">
  **Event Trigger:** Received via `CometChatCallDelegate.onCallEndedMessageReceived(endedCall:error:)`

  **endedCall (Call Object):**

  | Parameter     | Type                                            | Description                                                        |
  | ------------- | ----------------------------------------------- | ------------------------------------------------------------------ |
  | sessionId     | String                                          | Unique call session ID. Example: `"v1.us.12345.abcdef"`            |
  | callInitiator | [User](/sdk/ios/users-overview#user-properties) | User who initiated the call. Example: `{"uid": "cometchat-uid-1"}` |
  | callReceiver  | [User](/sdk/ios/users-overview#user-properties) | Other participant. Example: `{"uid": "cometchat-uid-2"}`           |
  | callStatus    | CallStatus                                      | Current call status. Example: `.ended`                             |
  | initiatedAt   | Double                                          | Unix timestamp when initiated. Example: `1699800000`               |
  | joinedAt      | Double?                                         | Unix timestamp when joined. Example: `1699800005`                  |
  | endedAt       | Double?                                         | Unix timestamp when ended. Example: `1699800300`                   |
</Accordion>

***

## Login Delegate Methods

The `CometChatLoginDelegate` provides you with live events related to login and logout. Below are the callback methods provided by the `CometChatLoginDelegate`.

| Method                                         | Information                                                |
| ---------------------------------------------- | ---------------------------------------------------------- |
| **onLoginSuccess(user: User)**                 | This event is triggered when a user successfully logs in.  |
| **onLoginFailed(error: CometChatException?)**  | This event is triggered when a login attempt fails.        |
| **onLogoutSuccess()**                          | This event is triggered when a user successfully logs out. |
| **onLogoutFailed(error: CometChatException?)** | This event is triggered when a logout attempt fails.       |

In order to receive login/logout events, you must add protocol conformance `CometChatLoginDelegate` as shown below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: CometChatLoginDelegate {

      func onLoginSuccess(user: User) {
        print("Login successful for user: " + user.stringValue())
      }

      func onLoginFailed(error: CometChatException?) {
        print("Login failed with error: " + (error?.errorDescription ?? "Unknown error"))
      }

      func onLogoutSuccess() {
        print("Logout successful")
      }

      func onLogoutFailed(error: CometChatException?) {
        print("Logout failed with error: " + (error?.errorDescription ?? "Unknown error"))
      }
    }
    ```
  </Tab>
</Tabs>

To add the login listener:

```swift theme={null}
CometChat.addLoginListener("unique_listener_id", self)
```

To remove the login listener:

```swift theme={null}
CometChat.removeLoginListener("unique_listener_id")
```

<Accordion title="Sample Payload - onLoginSuccess Event">
  **Event Trigger:** Received via `CometChatLoginDelegate.onLoginSuccess(user:)`

  **user ([User](/sdk/ios/users-overview#user-properties) Object):**

  | Parameter | Type                                                  | Description                                                            |
  | --------- | ----------------------------------------------------- | ---------------------------------------------------------------------- |
  | uid       | String?                                               | Unique identifier of the logged-in user. Example: `"cometchat-uid-1"`  |
  | name      | String?                                               | Display name. Example: `"Andrew Joseph"`                               |
  | avatar    | String?                                               | URL to the user's avatar. Example: `"https://assets.cometchat.io/..."` |
  | status    | [UserStatus](/sdk/ios/users-overview#userstatus-enum) | User's status. Example: `.online`                                      |
  | authToken | String?                                               | Authentication token. Example: `"abc123..."`                           |
</Accordion>

<Accordion title="Sample Payload - onLoginFailed Event">
  **Event Trigger:** Received via `CometChatLoginDelegate.onLoginFailed(error:)`

  **error (CometChatException Object):**

  | Parameter        | Type   | Description                                                        |
  | ---------------- | ------ | ------------------------------------------------------------------ |
  | errorCode        | String | Error code. Example: `"ERR_UID_NOT_FOUND"`                         |
  | errorDescription | String | Error message. Example: `"User with the given UID does not exist"` |
</Accordion>

<Accordion title="Sample Payload - onLogoutSuccess Event">
  **Event Trigger:** Received via `CometChatLoginDelegate.onLogoutSuccess()`

  | Parameter | Type | Description                           |
  | --------- | ---- | ------------------------------------- |
  | (none)    | Void | No parameters passed to this callback |

  **Effect:**

  | Action          | Description                         |
  | --------------- | ----------------------------------- |
  | Session cleared | User session and auth token cleared |
  | WebSocket       | Disconnected from real-time server  |
</Accordion>

***

## Connection Delegate Methods

The `CometChatConnectionDelegate` provides you with live events related to the WebSocket connection status. Below are the callback methods provided by the `CometChatConnectionDelegate`.

| Method                                           | Information                                                                   |
| ------------------------------------------------ | ----------------------------------------------------------------------------- |
| **connecting()**                                 | This event is triggered when the SDK is attempting to establish a connection. |
| **connected()**                                  | This event is triggered when the SDK successfully establishes a connection.   |
| **disconnected()**                               | This event is triggered when the SDK disconnects from the server.             |
| **onfeatureThrottled()**                         | This event is triggered when a feature is throttled due to rate limiting.     |
| **onConnectionError(error: CometChatException)** | This event is triggered when there is an error in the connection.             |

In order to receive connection events, you must add protocol conformance `CometChatConnectionDelegate` as shown below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: CometChatConnectionDelegate {

      func connecting() {
        print("Connecting to CometChat...")
      }

      func connected() {
        print("Connected to CometChat")
      }

      func disconnected() {
        print("Disconnected from CometChat")
      }

      func onfeatureThrottled() {
        print("Feature throttled")
      }

      func onConnectionError(error: CometChatException) {
        print("Connection error: " + error.errorDescription)
      }
    }
    ```
  </Tab>
</Tabs>

To add the connection listener:

```swift theme={null}
CometChat.addConnectionListener("unique_listener_id", self)
```

To remove the connection listener:

```swift theme={null}
CometChat.removeConnectionListener("unique_listener_id")
```

<Accordion title="Sample Payload - Connection Delegate Events">
  **connecting() Event:**

  | Parameter | Type | Description                           |
  | --------- | ---- | ------------------------------------- |
  | (none)    | Void | No parameters passed to this callback |

  **Event Trigger:** SDK is attempting to establish WebSocket connection

  **connected() Event:**

  | Parameter | Type | Description                           |
  | --------- | ---- | ------------------------------------- |
  | (none)    | Void | No parameters passed to this callback |

  **Event Trigger:** WebSocket connection successfully established

  **disconnected() Event:**

  | Parameter | Type | Description                           |
  | --------- | ---- | ------------------------------------- |
  | (none)    | Void | No parameters passed to this callback |

  **Event Trigger:** WebSocket connection lost

  **onfeatureThrottled() Event:**

  | Parameter | Type | Description                           |
  | --------- | ---- | ------------------------------------- |
  | (none)    | Void | No parameters passed to this callback |

  **Event Trigger:** Feature rate-limited due to excessive requests

  **onConnectionError(error:) Event:**

  | Parameter              | Type               | Description                                                |
  | ---------------------- | ------------------ | ---------------------------------------------------------- |
  | error                  | CometChatException | Connection error details                                   |
  | error.errorCode        | String             | Error code. Example: `"ERR_WEBSOCKET_ERROR"`               |
  | error.errorDescription | String             | Error message. Example: `"Failed to establish connection"` |

  **Connection Flow:**

  | Step | Event          | Description             |
  | ---- | -------------- | ----------------------- |
  | 1    | disconnected() | Connection breaks       |
  | 2    | connecting()   | SDK auto-reconnects     |
  | 3    | connected()    | Reconnection successful |
</Accordion>

***

## AI Assistant Events Delegate

The `AIAssistantEventsDelegate` provides you with live events related to AI Assistant features. Below are the callback methods provided by the `AIAssistantEventsDelegate`.

| Method                                                         | Information                                                     |
| -------------------------------------------------------------- | --------------------------------------------------------------- |
| **onAIAssistantEventReceived(\_ event: AIAssistantBaseEvent)** | This event is triggered when an AI Assistant event is received. |

In order to receive AI Assistant events, you must add protocol conformance `AIAssistantEventsDelegate` as shown below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: AIAssistantEventsDelegate {

      func onAIAssistantEventReceived(_ event: AIAssistantBaseEvent) {
        print("AI Assistant event received: " + event.stringValue())
      }
    }
    ```
  </Tab>
</Tabs>

To add the AI Assistant listener:

```swift theme={null}
CometChat.addAIAssistantListener("unique_listener_id", self)
```

To remove the AI Assistant listener:

```swift theme={null}
CometChat.removeAIAssistantListener("unique_listener_id")
```

<Accordion title="Sample Payload - onAIAssistantEventReceived Event">
  **Event Trigger:** Received via `AIAssistantEventsDelegate.onAIAssistantEventReceived(_:)`

  **event (AIAssistantBaseEvent Object):**

  | Parameter | Type   | Description                                                                               |
  | --------- | ------ | ----------------------------------------------------------------------------------------- |
  | type      | String | Event type identifier. Example: `"run_start"`, `"text_message_content"`, `"run_finished"` |
  | id        | String | Run ID for the event. Example: `"run_abc123"`                                             |

  **Event Types:**

  | Type                   | Description                        |
  | ---------------------- | ---------------------------------- |
  | `run_start`            | New AI run has begun               |
  | `tool_call_start`      | Agent decided to invoke a tool     |
  | `tool_call_arguments`  | Arguments being passed to the tool |
  | `tool_call_end`        | Tool execution completed           |
  | `tool_call_result`     | Tool's output is available         |
  | `text_message_start`   | Agent started composing a reply    |
  | `text_message_content` | Streaming content chunk            |
  | `text_message_end`     | Agent reply is complete            |
  | `run_finished`         | Run is finalized                   |
</Accordion>

***
