> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Message List

> The scrolling conversation of a chat: bubbles for every message kind, receipts, reactions, replies and threads, the option menu, pin and save, and AI.

`CometChatMessageList` is the scrolling conversation between the header and the composer.
It fetches a chat's messages, pages back through history, stays live, and draws every
message kind as a bubble: text, images and videos, files, audio and voice notes, stickers,
polls, meetings, collaborative documents, cards and AI replies.

![CometChatMessageList showing a group conversation with incoming and outgoing messages, a thread reply count and a missed-call entry](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-message-list.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=8493dbfe444d8f5cf81662d8ecec77e0)

***

## Where It Fits

Place it between the message header and the message composer, and give it the chat's `User`
or `Group` — and a parent message for a thread.

```
CometChatConversations / CometChatUsers
        │ onItemClick
        ▼
┌─────────────────────────────┐
│ message header              │
│ CometChatMessageList ← here │
│ message composer            │
└─────────────────────────────┘
```

It fetches the latest page itself and listens to the SDK and the Kit's event bus, so what the
composer sends appears at once. Its **Edit** and **Reply** options reach the composer through
the bus — no wiring. State lives in a `MessageListStore`, shared by both toolkits.

***

## Quick Start

> [tab] SwiftUI
>
> The list fills the screen, and the header and the composer are bars over it. The rows scroll
> under their Liquid Glass on iOS 26 and still come to rest clear of them. Host the bars with
> `safeAreaBar` on iOS 26: it also carries the list's scroll edge effect under each bar, so the
> rows fade softly behind it. Earlier versions have no edge effect, and `safeAreaInset` hosts the
> bars the same way. Stacked in a `VStack` instead, nothing passes under the bars and the glass
> has nothing to show.
>
> ```swift theme={null}
> struct ChatScreen: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         CometChatMessageList(user: user)
>             .modifier(ChatBars(
>                 header: CometChatMessageHeader(user: user),
>                 composer: CometChatMessageComposer(user: user)))
>     }
> }
>
> /// The header and the composer as bars over the list: the rows scroll under them and rest clear of them.
> struct ChatBars<Header: View, Composer: View>: ViewModifier {
>     let header: Header
>     let composer: Composer
>
>     func body(content: Content) -> some View {
>         let list = content.frame(maxWidth: .infinity, maxHeight: .infinity)
>         if #available(iOS 26.0, *) {
>             // The list's scroll edge effect reaches under each bar: the rows fade softly behind it.
>             list
>                 .safeAreaBar(edge: .top, spacing: 0) { header }
>                 .safeAreaBar(edge: .bottom, spacing: 0) { composer }
>         } else {
>             list
>                 .safeAreaInset(edge: .top, spacing: 0) { header }
>                 .safeAreaInset(edge: .bottom, spacing: 0) { composer }
>         }
>     }
> }
> ```
>
> ![The SwiftUI message list: an incoming image with reactions, an outgoing reply quoting it with 3 Replies under it, a missed call, the New separator, an edited and a deleted message, a pinned message and a failed send](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListMixed.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=d1afd10cac22a4e9d085b7e6ff226d42)

> [tab] UIKit
>
> `CometChatMessageList` is a `UIView` over a `UITableView`. The list spans the screen, and the
> header and the composer sit over it, the composer on the keyboard layout guide so it rides above
> the keyboard. The rows scroll under their Liquid Glass on iOS 26. Two things make that work:
>
> * **The bars' heights are the list's safe area.** The list sits in a view controller of its own, and the
>   bars' heights reach it as that controller's `additionalSafeAreaInsets`. The list turns them into its
>   table's content inset, so the first and last rows still come to rest clear of the bars.
> * **Each bar is the table's scroll edge element (iOS 26).** A `UIScrollEdgeElementContainerInteraction`
>   on each bar carries the table's scroll edge effect under it, so the rows fade softly behind the bar.
>   Earlier versions have no edge effect and skip it.
>
> Pinned one below the other instead, nothing passes under the bars and the glass has nothing to show.
>
> The menu, alerts, viewers and share sheet are presented by the view controller that owns the list.
>
> The header is the screen's bar. Keep the navigation bar, empty and clear, instead of hiding it: a
> hidden bar comes back when the swipe back starts and is drawn over the chat, with the list's search
> field in it. A bar that stays cross-fades to the list's. Take its height back off the screen's safe
> area so the header keeps its place under the status bar. The header's back button is hidden by default
> and never pops by itself:
>
> ```swift theme={null}
> final class ChatViewController: UIViewController {
>     var user: CometChatSDK.User!
>     private let header = CometChatMessageHeader()
>     private let composer = CometChatMessageComposer()
>     /// Holds the list, so the bars' heights can reach it as safe area.
>     private let listController = MessageListController()
>     private var messageList: CometChatMessageList { listController.messageList }
>
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         view.backgroundColor = .systemBackground
>         clearNavigationBar()
>         header.set(user: user)
>         messageList.set(user: user)
>         composer.set(user: user)
>         header.hideBackButton = false
>         header.set(onBack: { [weak self] in self?.navigationController?.popViewController(animated: true) })
>
>         // The list first, so the bars sit over it.
>         addChild(listController)
>         for part in [listController.view, header, composer] as [UIView] {
>             part.translatesAutoresizingMaskIntoConstraints = false
>             view.addSubview(part)
>         }
>         listController.didMove(toParent: self)
>         NSLayoutConstraint.activate([
>             listController.view.topAnchor.constraint(equalTo: view.topAnchor),
>             listController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
>             listController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
>             // To the composer's bottom: the rows pass under the composer, never under the keyboard.
>             listController.view.bottomAnchor.constraint(equalTo: composer.bottomAnchor),
>
>             header.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
>             header.leadingAnchor.constraint(equalTo: view.leadingAnchor),
>             header.trailingAnchor.constraint(equalTo: view.trailingAnchor),
>
>             composer.leadingAnchor.constraint(equalTo: view.leadingAnchor),
>             composer.trailingAnchor.constraint(equalTo: view.trailingAnchor),
>             composer.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
>         ])
>
>         if #available(iOS 26.0, *) {
>             // The table's scroll edge effect reaches under each bar: the rows fade softly behind it.
>             for (bar, edge) in [(header as UIView, UIRectEdge.top), (composer, .bottom)] {
>                 let element = UIScrollEdgeElementContainerInteraction()
>                 element.scrollView = messageList.tableView
>                 element.edge = edge
>                 bar.addInteraction(element)
>             }
>         }
>     }
>
>     // The bars' heights, as the list's safe area. The composer's grows with the keyboard and a reply
>     // preview, and the list keeps its newest row clear of it.
>     override func viewDidLayoutSubviews() {
>         super.viewDidLayoutSubviews()
>         let container: UIView = listController.view
>         // The list's safe area is the screen's (the status bar, the home indicator) plus `added`.
>         let added = listController.additionalSafeAreaInsets
>         let inherited = container.safeAreaInsets
>         let headerBottom = view.convert(header.frame, to: container).maxY
>         let composerTop = view.convert(composer.frame, to: container).minY
>         let insets = UIEdgeInsets(
>             top: max(0, headerBottom - (inherited.top - added.top)),
>             left: 0,
>             bottom: max(0, container.bounds.maxY - composerTop - (inherited.bottom - added.bottom)),
>             right: 0)
>         if insets != added { listController.additionalSafeAreaInsets = insets }
>     }
>
>     // The header is the screen's bar: the navigation bar stays, empty and clear. Hidden, it would
>     // come back when the swipe back starts, drawn over the chat with the list's search field in it.
>     private func clearNavigationBar() {
>         let appearance = UINavigationBarAppearance()
>         appearance.configureWithTransparentBackground()
>         navigationItem.standardAppearance = appearance
>         navigationItem.scrollEdgeAppearance = appearance
>         navigationItem.compactAppearance = appearance
>         navigationItem.compactScrollEdgeAppearance = appearance
>         navigationItem.title = ""
>         navigationItem.largeTitleDisplayMode = .never
>         navigationItem.hidesBackButton = true
>     }
>
>     // The bar's height, taken back off the screen's safe area: the header keeps its place under the
>     // status bar and the bar lies over it. The bar has no items, so every touch reaches the header.
>     override func viewWillLayoutSubviews() {
>         super.viewWillLayoutSubviews()
>         var barHeight: CGFloat = 0
>         if let navigation = navigationController, !navigation.isNavigationBarHidden {
>             barHeight = navigation.navigationBar.frame.height
>         }
>         if additionalSafeAreaInsets.top != -barHeight { additionalSafeAreaInsets.top = -barHeight }
>     }
> }
>
> /// The list, full-bleed, in a view controller of its own: its `additionalSafeAreaInsets` are how the
> /// bars' heights reach the list.
> final class MessageListController: UIViewController {
>     let messageList = CometChatMessageList()
>
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         messageList.translatesAutoresizingMaskIntoConstraints = false
>         view.addSubview(messageList)
>         NSLayoutConstraint.activate([
>             messageList.topAnchor.constraint(equalTo: view.topAnchor),
>             messageList.leadingAnchor.constraint(equalTo: view.leadingAnchor),
>             messageList.trailingAnchor.constraint(equalTo: view.trailingAnchor),
>             messageList.bottomAnchor.constraint(equalTo: view.bottomAnchor),
>         ])
>     }
> }
> ```
>
> ![The UIKit message list: a Today date separator, an incoming message with a 👍 reaction chip and a 2 Replies thread row, a reply quoting it, and the New separator above the last message](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitMessageList.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5c4239f39c19501c85edc4fc737198c9)

[Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md#step-2-set-up-the-message-screen) builds the whole chat screen this way.

A group works the same way. For a thread, pass the thread's root message:

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatMessageList(group: group)
> CometChatMessageList(group: group, parentMessage: parentMessage)
> ```
>
> > [!NOTE]
> >
> > `parentMessageId` still works but is **deprecated**: it is read only when
> > `parentMessage` is `nil`. Pass the message, so replies arriving live carry its thread
> > subscription state.
>
> With `autoFetch: false` the list takes the chat but fetches nothing. `user` wins when both
> `user` and `group` are given, but the chat still counts as a group for avatars and names.

> [tab] UIKit
>
> ```swift theme={null}
> messageList.set(group: designTeam)
> messageList.set(group: designTeam, parentMessage: threadParent)
> ```
>
> > [!NOTE]
> >
> > `set(parentMessageId:)` still works but is **deprecated**: it applies at the next
> > `set(user:)` / `set(group:)`, and only when no parent message is set.

***

## Filtering Messages

The list's default request fetches only the Kit's own message types. A request builder
replaces it whole: the list adds the user or group, so set the types, categories, page size,
`hideReplies` and — for a thread — the parent message id yourself.

> [tab] SwiftUI
>
> Pass `messagesRequestBuilder`, a closure that returns the builder. Live messages are filtered by
> the same types.

> [tab] UIKit
>
> Call `set(messagesRequestBuilder:)` **before** `set(user:)` / `set(group:)`.

A custom message type needs its own entry in the builder's types. [Your Own Bubble](#your-own-bubble)
shows a complete example.

***

## What the List Shows

> [tab] SwiftUI
>
> | State | Shows |
> | - | - |
> | loading | a shimmer — `loadingView` replaces it, `hideLoadingState` hides it |
> | empty | "No Messages Yet" over "Say hi to *name*" — `emptyView` replaces it, `hideEmptyState` hides it |
> | error | "Something went wrong." with a retry, which fetches the older page again — `errorView` replaces it, `hideErrorState` hides it |
> | messages | the rows, oldest at the top, newest at the bottom |
>
> The list opens at the newest message. Scrolling to the top loads the older page, with a
> spinner above the first row; after a jump, scrolling to the bottom loads newer messages the
> same way.
>
> > [!WARNING]
> >
> > **A failed older page replaces the rows** with the error view — even when messages were
> > already showing — and calls `onError`. With `hideErrorState` the list shows nothing until a
> > retry.

> [tab] UIKit
>
> | State | Shows | Replace with | Hide with |
> | - | - | - | - |
> | loading | a shimmer | `set(loadingView:)` | `hideLoadingView` |
> | empty | "Say Hello to *name* 👋" over "Start a conversation"; in a group, "No Messages Yet" over "Be the first to send a message" | `set(emptyView:)`, or `emptyTitleText` / `emptySubtitleText` | `hideEmptyView` |
> | error | "Oops!" over "Looks like something went wrong. Please try again." | `set(errorView:)`, or `errorTitleText` / `errorSubtitleText` | `hideErrorView` |
> | messages | the rows, oldest at the top | — | — |
>
> The list opens at the newest message. **Dragging** to the very first row loads the older
> page, with a spinner above it; after a jump, dragging to the very last row loads newer
> messages.
>
> > [!WARNING]
> >
> > A page loads **only while you drag**, at the very first or last row. Scrolling to the top
> > in code never loads older messages. A failed older page hides the rows behind the error
> > view.

### Separators and the Sticky Date

> [tab] SwiftUI
>
> A **date separator** heads each day: "Today", "Yesterday", then a date. While the list
> scrolls, the top row's day stays pinned as a **sticky date**. With
> `startFromUnreadMessages: true` the list opens at the first unread message, marked by a
> **new-messages separator**.
>
> | Parameter | Hides |
> | - | - |
> | `hideDateSeparator` | the date separators |
> | `hideStickyDate` | the sticky date |
> | `hideNewMessagesSeparator` | the new-messages separator |
>
> ![The message list spanning several days: date separators reading June 3, 2026, June 12, 2026, Yesterday and Today above each day's messages](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListDays.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=8fc0cea40a7ee05455457f6c8cf1a360)

> [tab] UIKit
>
> A date separator heads each day, and the top row's day stays pinned while you scroll.
> `hideDateSeparator` hides both. With `startFromUnreadMessages = true` the list opens at the
> first unread message, marked by the unread separator — `hideUnreadSeparator` hides it.

### New Messages and the Indicator

> [tab] SwiftUI
>
> At the bottom, the list follows new messages. Scrolled up, it stays where it is and shows
> the **new-message indicator** — an arrow with a count, "999+" at most. A tap scrolls to the
> newest message; when newer pages are not loaded yet, it fetches the latest page first.
>
> > [!NOTE]
> >
> > `scrollToBottomOnNewMessage: false` does not stop a list that is already at the bottom
> > from following new messages: within five rows of the end, it always scrolls.
>
> Reaching the bottom marks the newest message read and clears the unread count.
> `disableReceipt: true` sends no delivery or read receipts.

> [tab] UIKit
>
> At the bottom, the list follows new messages. Scrolled up, it shows the new-message
> indicator — a round button over the bottom-trailing corner. A tap calls
> `scrollToBottom(isAnimated:)`, which fetches the latest page first when newer pages are not
> loaded. `hideNewMessageIndicator` hides it; `scrollToBottomOnNewMessages = false` stops
> the automatic scroll.
>
> > [!NOTE]
> >
> > The indicator's count is never raised, so its badge never shows, and
> > `set(newMessageIndicatorView:)` keeps your view without showing it.
>
> While you rest at the bottom, the newest message stays on the composer when rows change
> under it without a new message: the unread separator appearing, a message removed, a row
> growing or shrinking. Scrolled up, the row you are reading stays where it is. When an older
> page loads above, the row you are reading also stays put, at the bottom or not.

### Jumping to a Message

> [tab] SwiftUI
>
> `goToMessageId` scrolls to a message and highlights it — from a search result, say. It is
> a binding: the list sets it back to `nil` when the jump lands, so the same id can be sent
> again.
>
> ```swift theme={null}
> struct SearchableChat: View {
>     let group: CometChatSDK.Group
>     @State private var jumpTo: MessageID?
>
>     var body: some View {
>         CometChatMessageList(group: group, goToMessageId: $jumpTo)
>             .toolbar { Button("Pinned") { jumpTo = 4215 } }
>     }
> }
> ```
>
> A message that is not loaded is fetched with its neighbours. Tapping a reply's quote jumps
> the same way.

> [tab] UIKit
>
> ```swift theme={null}
> messageList.goToMessage(withId: 4215)
> messageList.goToMessage(withId: 4215, highlight: false)
> ```
>
> Before `set(user:)` / `set(group:)` the id waits for them. A message that is not loaded is
> fetched with its neighbours; with `highlight` its row is highlighted. Tapping a reply's
> quote jumps the same way.

***

## Rows

> [tab] SwiftUI
>
> Your messages sit on the trailing side, everyone else's on the leading side, and group
> actions and calls are centred. `messageAlignment: .leftAligned` draws every message on the
> leading side, as incoming.
>
> An incoming row shows the sender's **avatar** and **name** in a group — never in a
> one-to-one chat, except the avatar in a chat with an AI agent. `hideAvatar: true` removes
> the avatar.
>
> The **status line** under a bubble holds, in order: a pin and a bookmark when the message is
> pinned or saved, "edited", the time, and on your own messages the receipt — a clock while
> sending, then sent, delivered and read, or an error when the send failed. There is no retry.
> `timeStampAlignment: .top` moves the time up beside the sender's name.
>
> > [!NOTE]
> >
> > `hideReceipts` has **no effect**: receipts stay. Replace the status line with a
> > [row slot](#custom-view-slots) to remove them.
>
> Consecutive messages from one sender are not grouped: each has its own avatar, name and
> status line. The one grouping is a batch: with `enableMultipleAttachments` on — the default —
> attachments sent together draw as a group, the avatar on the first and the receipt on the
> last.

> [tab] UIKit
>
> Your messages sit on the right, everyone else's on the left, and group actions and calls
> are centred. `messageAlignment = .leftAligned` puts every message on the left; the receipt
> stays on your own.
>
> In a group an incoming row shows the sender's avatar and name.
>
> > [!WARNING]
> >
> > Setting `hideAvatar` to `false` puts an avatar on **every** incoming row, one-to-one chats
> > included, and setting it to `true` only undoes that — a group's avatars stay.
>
> The status line under a bubble holds a pin and a bookmark when the message is pinned or
> saved, "edited", the time, and on your own messages the receipt: a clock while sending,
> then sent, delivered and read, or an error when the send failed. `hideReceipts = true`
> hides the receipts.
>
> `hideGroupActionMessages` hides group actions — calls stay. A hidden action keeps its
> place, so a day holding only actions still shows its date separator.

***

## Bubbles

Every message kind is drawn by a built-in bubble.

> [tab] SwiftUI
>
> Each kind is drawn by a **bubble factory**. The built-ins:
>
> | Kind | `MessageKind` | Factory | Draws |
> | - | - | - | - |
> | Text | `.text` | `TextBubbleFactory` | markdown, mentions, code, quotes and lists, and a translation under the text; a link opens through `openURL` |
> | Image, Video | `.image`, `.video` | `ImageBubbleFactory`, `VideoBubbleFactory` | a grid of 1…N with "+N"; a tap opens the Kit's viewer |
> | File | `.file` | `FileBubbleFactory` | file cards, "Show more"; a tap opens the file, the icon downloads it |
> | Audio, Voice note | `.audio`, `.voiceNote` | `AudioBubbleFactory`, `VoiceNoteBubbleFactory` | an inline player |
> | Sticker | `.sticker` | `StickerBubbleFactory` | the sticker, without a bubble |
> | Poll | `.poll` | `PollBubbleFactory` | the question and options with results; a tap votes |
> | Meeting | `.meeting` | `MeetingBubbleFactory` | a call card with **Join** |
> | Document, Whiteboard | `.document`, `.whiteboard` | `CollaborativeBubbleFactory(kind:)` | a banner with **Open**, which opens the link |
> | Card | `.card` | `CardBubbleFactory` | the card, with its actions |
> | AI reply | `.aiAssistant` | `AIAssistantBubbleFactory` | the agent's reply: thinking, streaming, then markdown and cards |
> | Group action | `.groupAction` | `GroupActionBubbleFactory` | a centred line — "Alice added Kabir" |
> | Call | `.audioCall`, `.videoCall` | `CallActionBubbleFactory(kind:)` | a centred call line, missed calls styled apart |
>
> A **deleted** message of any kind draws the tombstone, "This message was deleted", and a
> kind nothing draws shows "Unsupported: *category\_type*" — never a blank row. The unsupported
> text is English in every language.
>
> `enableMultipleAttachments: false` switches image, video, file and audio messages to the
> older single-attachment bubbles, and stops batch grouping.

> [tab] UIKit
>
> | Kind | `category` / `type` | Draws |
> | - | - | - |
> | Text | `message` / `text` | markdown, mentions, code, a link preview, and a translation under the text |
> | Image, Video | `message` / `image`, `video` | a grid of 1…N; a tap opens the Kit's viewer |
> | File | `message` / `file` | file cards; a tap opens the tapped file, the icon downloads it |
> | Audio, voice note | `message` / `audio` | an inline player, one playing at a time |
> | Sticker | `custom` / `extension_sticker` | the sticker, animating GIFs |
> | Poll | `custom` / `extension_poll` | the options with results; a tap votes |
> | Meeting | `custom` / `meeting` | a call card with **Join** |
> | Document, Whiteboard | `custom` / `extension_document`, `extension_whiteboard` | a banner with **Open** |
> | Card | `card` / `card` | the card; an action goes out as the `cardActionClicked` UI event |
> | AI reply | `agentic` / `assistant` | thinking, streaming, then markdown and cards, with a copy button |
> | Group action, call | `action` / `groupMember`, `call` / `audio`, `video` | a centred line |
>
> A deleted message draws "This message was deleted", and a kind nothing draws shows
> "Unsupported: *category\_type*". `set(enableMultipleAttachments: false)` switches media and
> files to the older single-attachment bubbles.
>
> > [!NOTE]
> >
> > A meeting's **Join** joins the meeting and presents the Kit's ongoing-call screen. A
> > document's or whiteboard's **Open** opens its link in the Kit's web view, pushed on your
> > navigation controller — or presented in one, with a close button, when the list has none.
> > A text message with both a link preview and a translation shows only the preview.

### Your Own Bubble

> [tab] SwiftUI
>
> A factory names a `MessageKind` and draws its `content`. Register it with
> `bubbleFactories`; it replaces any built-in for the same kind, and the last one registered
> wins. Ask the request builder for your type too (see [Filtering Messages](#filtering-messages)):
>
> ```swift theme={null}
> struct LocationBubbleFactory: BubbleFactory {
>     var kind: MessageKind { MessageKind(category: "custom", type: "location") }
>
>     @MainActor func content(_ message: ChatMessage, _ alignment: MessageAlignment) -> AnyView {
>         var place = "Shared location"
>         if case .string(let name)? = message.custom?.data["name"] { place = name }
>         return AnyView(Label(place, systemImage: "mappin.and.ellipse").padding(12))
>     }
> }
>
> struct ChatScreen: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         CometChatMessageList(
>             user: user,
>             messagesRequestBuilder: {
>                 MessagesRequest.MessageRequestBuilder()
>                     .set(types: MessageListStore.defaultMessagesTypes + ["location"])
>                     .set(categories: MessageListStore.defaultMessagesCategories)
>                     .set(limit: 30)
>                     .hideReplies(hide: true)
>             },
>             bubbleFactories: [LocationBubbleFactory()]
>         )
>     }
> }
> ```
>
> A factory draws only what it returns. Every other region — avatar, name, quote, status
> line, moderation notice, reactions, "N replies" — keeps the list's default. A factory can
> return any of them too, or `bubbleView` to replace the whole row:
>
> | Factory member | Region |
> | - | - |
> | `content` *(required)* | the payload |
> | `leadingView`, `headerView`, `replyView` | avatar, sender name, quote |
> | `statusInfoView`, `bottomView` | the time and receipt line, the moderation notice |
> | `threadView`, `footerView` | "N replies", the reactions |
> | `bubbleView` | the whole row — no other member is asked |
> | `style(for:)` | the bubble's container style |
>
> Keep a built-in's content and change one region by delegating to it:
>
> ```swift theme={null}
> struct StarredTextFactory: BubbleFactory {
>     let base = TextBubbleFactory()
>     var kind: MessageKind { .text }
>
>     @MainActor func content(_ message: ChatMessage, _ alignment: MessageAlignment) -> AnyView {
>         base.content(message, alignment)
>     }
>
>     @MainActor func footerView(_ message: ChatMessage, _ alignment: MessageAlignment) -> AnyView? {
>         message.isPinned ? AnyView(Image(systemName: "star.fill").font(.caption2)) : nil
>     }
> }
> ```
>
> > [!WARNING]
> >
> > * A deleted message always draws the built-in tombstone. No factory can replace it.
> > * Registering a factory for `.groupAction`, `.audioCall` or `.videoCall` gives those
> >   centred rows the full chrome — name, status line and reactions.

> [tab] UIKit
>
> A `CometChatMessageTemplate` draws one kind, keyed by `category` and `type`. Each closure
> receives the SDK message, its side (`MessageBubbleAlignment`) and the view controller the list
> is in. A closure that returns a view wins for its region; `nil`, or no closure, keeps the
> built-in.
>
> | Closure | Region |
> | - | - |
> | `contentView` | the payload |
> | `leadingView` *(property only)* | the avatar |
> | `headerView` | the sender's name |
> | `replyView` | the quoted message |
> | `statusInfoView` | the time and receipt line |
> | `bottomView` | the moderation notice |
> | `threadView` *(property only)* | "N replies" |
> | `footerView` | the reactions |
> | `bubbleView` | the whole row — no other closure is asked |
> | `options` | the kind's menu, when it returns non-`nil` |
>
> Change one region of a built-in:
>
> ```swift theme={null}
> let pinnedStar = CometChatMessageTemplate(category: "message", type: "text", footerView: { message, _, _ in
>     guard message?.pinnedAt ?? 0 > 0 else { return nil }
>     return UIImageView(image: UIImage(systemName: "star.fill"))
> })
> messageList.add(templates: [pinnedStar])
> ```
>
> Or draw a type of your own. Ask the request builder for it too — **before** `set(user:)`:
>
> ```swift theme={null}
> let location = CometChatMessageTemplate(category: "custom", type: "location", contentView: { message, _, _ in
>     let label = UILabel()
>     label.numberOfLines = 0
>     label.text = (message as? CustomMessage)?.customData?["name"] as? String ?? "Shared location"
>     return label
> })
>
> let request = MessagesRequest.MessageRequestBuilder()
>     .set(types: MessageListStore.defaultMessagesTypes + ["location"])
>     .set(categories: MessageListStore.defaultMessagesCategories)
>     .set(limit: 30)
>     .hideReplies(hide: true)
>
> messageList
>     .set(messagesRequestBuilder: request)
>     .add(templates: [location])
>     .set(user: user)
> ```
>
> `set(templates:)` replaces the list's templates; `add(templates:)` adds them, one per kind,
> the last winning. A `message` / `audio` template draws voice notes too.
>
> > [!WARNING]
> >
> > A deleted message always draws the built-in tombstone, whatever a template registers.

### Bubble Taps

> [tab] SwiftUI
>
> | Tap | Does |
> | - | - |
> | an image or video | opens the Kit's image or video viewer; "+N" opens it at the first item |
> | a file | opens the message's first file — in Quick Look when it is on the device, else its link |
> | a download icon | saves the file to your app's `Documents` folder, with no toast |
> | a poll option | votes through the Polls extension |
> | a document or whiteboard's **Open** | opens its link with `openURL` |
> | a card action | goes out as the Kit's `cardActionClicked` UI event |
> | a meeting's **Join** | joins the meeting and shows the Kit's ongoing-call screen |
> | a link in a text message | opens with `openURL` |
> | a user mention | opens that user's chat: an `openChat` UI event — see [Mentions](#mentions) |
> | a mention-all | nothing |
>
> To take over a tap, register the built-in factory with its callback — it replaces the
> default for that kind:
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     bubbleFactories: [
>         TextBubbleFactory(onLinkClick: { url in log("opened \(url)") },
>                           onMentionClick: { user in log("mention \(user.name)") }),
>         MeetingBubbleFactory(onJoinClick: { sessionID in joinMeeting(sessionID: sessionID) })
>     ]
> )
> ```
>
> > [!NOTE]
> >
> > **Join** joins the meeting through the Kit's call coordinator and shows the ongoing-call
> > screen, reading the session id from the message. To handle it yourself, use
> > `MeetingBubbleFactory(onJoinClick:)`, or for every list in a subtree
> > `.cometChatMeetingJoinClick(MessageMeetingJoinAction { message, sessionID in … })`. The
> > session id `onJoinClick` receives is empty for meetings the Kit sent; read it from the
> > message instead.

> [tab] UIKit
>
> The taps are described in the table under [Bubbles](#bubbles). A tap on a user mention is
> covered under [Mentions](#mentions).

***

## Reactions

> [tab] SwiftUI
>
> Reactions show under the bubble: up to four chips, then a "+N" chip for the rest, and an
> add button. A chip shows its count, and is highlighted when you reacted with it. Tapping a
> chip **toggles** your reaction — `onReactionClick` replaces that. The row changes only when
> the server confirms.
>
> ![Messages with reaction chips and an add-reaction button under the bubbles, the chips the user reacted with highlighted](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListReactions.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=49465fe7afd0f94be5696cae36b9f980)
>
> The add button, "+N", and the add-reaction button in the long-press menu open the
> [emoji keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/emoji-keyboard.md) in a 400 pt sheet. Picking an emoji
> **adds** it — one you have already reacted with is sent again, not removed — and
> closes the sheet. From the menu, the menu closes first and the sheet rises after it.
>
> * `onAddMoreReactionsClick` replaces the sheet for "+N" and the add button.
> * `onEmojiPickerClick` replaces it for the menu's button. It is called while the menu is still
>   on screen, with the message.
>
> Long-pressing a chip opens the [reaction list](https://www.cometchat.com/docs/ui-kit/ios/v6/reaction-list.md) in a
> half-height sheet with a grabber: who reacted, under a tab per emoji, opened on All. Tapping your
> own row removes your reaction; the sheet closes when the last one is gone.
>
> * `onReactionLongClick` replaces the sheet.
> * `reactionsRequestBuilder` and `reactionListStyle` reach the sheet — or style it from above the
>   list with `.cometChatMessageListReactionListStyle(_:)`; the parameter wins when set.
>
> ```swift theme={null}
> struct ChatWithStyledReactions: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         CometChatMessageList(user: user,
>                              reactionListStyle: CometChatReactionListStyle(tabActiveIndicatorColor: .orange),
>                              reactionsRequestBuilder: ReactionsRequestBuilder().set(limit: 20))
>     }
> }
> ```
>
> `hideReactions: true` removes the chips. A `footerView` slot still shows.

> [tab] UIKit
>
> Reactions show under the bubble as chips, a "+N" chip for the rest. Tapping a chip
> **toggles** your reaction; `set(onReactionClick:)` replaces that. The row changes when the
> server confirms. `hideReactions = true` removes the chips.
>
> "+N" opens the emoji keyboard in a 400 pt sheet; `set(onAddMoreReactionsClick:)` replaces it.
> Picking an emoji **adds** it — one you already reacted with is sent again, never removed — and
> closes the sheet. `emojiKeyboardStyle` styles every [emoji keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/emoji-keyboard.md)
> the list presents:
>
> ```swift theme={null}
> let list = CometChatMessageList()
> list.emojiKeyboardStyle.selectedCategoryIconTint = .systemOrange
> ```
>
> A chip's long press presents the [reaction list](https://www.cometchat.com/docs/ui-kit/ios/v6/reaction-list.md) in a
> `.medium()` sheet with a grabber, opened on All; `set(onReactionLongClick:)` replaces it. The sheet
> gets the list's `reactionListConfiguration` and `set(reactionsRequestBuilder:)`, and a tap on
> one of its rows calls `set(onReactionListItemClick:)` and the
> delegate's `onReactionListItemClick(reaction:message:)`. The sheet dismisses when the last
> reaction is gone.
>
> ```swift theme={null}
> let configuration = ReactionListConfiguration()
>     .set(style: ReactionListStyle())
> let list = CometChatMessageList()
>     .set(reactionListConfiguration: configuration)
>     .set(reactionsRequestBuilder: ReactionsRequestBuilder().set(limit: 20))
>     .set(onReactionListItemClick: { reaction, message in print(reaction.uid) })
> ```

***

## Replies and Threads

> [tab] SwiftUI
>
> A **reply** carries a quote of the message it answers. Tapping the quote jumps to that
> message. Swiping a row toward the trailing edge replies to it, as the Reply option does —
> `swipeToReplyEnabled: false` turns that off. There is no swipe on actions, calls, AI
> replies, unsent or deleted messages, or in a chat with an AI agent.
>
> A message with replies shows "N replies" under it. Tapping it, or choosing **Reply in
> thread**, calls `onThreadRepliesClick` with the thread's root. Show the thread in its own
> list, with the [thread header](https://www.cometchat.com/docs/ui-kit/ios/v6/thread-header.md) and the composer as bars
> over it — `ChatBars` from [Quick Start](#quick-start):
>
> ```swift theme={null}
> struct ThreadScreen: View {
>     let group: CometChatSDK.Group
>     let root: BaseMessage
>
>     var body: some View {
>         CometChatMessageList(group: group, parentMessage: root)
>             .modifier(ChatBars(
>                 header: CometChatThreadHeader(parentMessage: root),
>                 composer: CometChatMessageComposer(group: group, parentMessageId: root.id)))
>     }
> }
> ```
>
> ```swift theme={null}
> CometChatMessageList(group: group, onThreadRepliesClick: { root in openThread(root) })
> ```
>
> In a thread there is no Reply in thread and no Mark as unread.

> [tab] UIKit
>
> A reply carries a quote; tapping it jumps to the quoted message. Swiping a row replies to
> it, as the Reply option does — `disableSwipeToReply = true` turns that off.
>
> A message with replies shows "N replies" under it. Tapping it, or choosing **Reply in
> thread**, calls `set(onThreadRepliesClick:)` with the root and its kind's template. Show
> the thread in its own list:
>
> ```swift theme={null}
> messageList.set(onThreadRepliesClick: { root, _ in openThread(root) })
>
> let thread = CometChatMessageList()
> thread.set(group: designTeam, parentMessage: threadParent)
> ```
>
> `style.threadedMessageImage` replaces the thread row's glyph.

***

## Thread Subscription

The **Subscribe to thread** option subscribes you to a message's thread, and turns into
**Unsubscribe from thread** once you are. It needs thread subscriptions on for your app.
`hideThreadSubscriptionOption` removes it.

> [tab] SwiftUI
>
> The result shows as a toast:
>
> | Result | Toast |
> | - | - |
> | subscribed | "Subscribed. You'll be notified about new replies in this thread." |
> | unsubscribed | "Unsubscribed. Notifications are off until you reply or are mentioned." |
> | failed | "Couldn't update. Please try again." |
>
> On a message with no replies yet the two success toasts are shorter. A subscription changed
> elsewhere — another list, another device — updates the option.

> [tab] UIKit
>
> A toast confirms it — "Subscribed. You'll be notified about new replies in this thread." — or
> says it failed.

***

## Pin and Save

Pin, Unpin, Save and Unsave appear only when your app has the pin or save feature turned on.
**Pin** and **Save** act at once; **Unpin** and **Unsave** ask first, in an alert that a
tap outside does not dismiss. A toast says how it went.

> [tab] SwiftUI
>
> The toast reads "Message pinned", "Message saved"…, the app's limit — "You can only pin 3
> messages. Unpin one to pin another." — a missing permission, or a generic failure.
>
> ![Pinned and saved messages: a pin, a bookmark or both before the time on each status line](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListPinSave.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=d47ad6e32b6b57600a4024707653ec49)
>
> The row changes when the server's update arrives, not when you tap. A pinned or saved
> message shows a pin or a bookmark before its time. There is no per-list flag for these
> options: they follow your app's settings. The pinned and saved **lists** belong to other
> screens.

> [tab] UIKit
>
> The row changes when the server's update arrives, not when you tap. There is no per-list flag
> for these options: they follow your app's settings.

***

## AI

### Conversation Starters, Smart Replies and Summary

> [tab] SwiftUI
>
> Three optional panels, each off by default:
>
> | Parameter | Shows |
> | - | - |
> | `enableConversationStarter` | suggested openers in an empty chat |
> | `enableSmartReplies` | suggested answers to the last incoming text, above the composer |
> | `enableConversationSummary` | a summary at the top, when more than `unreadMessageThreshold` messages are unread |
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     enableConversationStarter: true,
>     enableSmartReplies: true,
>     enableConversationSummary: true,
>     smartRepliesKeywords: ["?", "when", "where"],
>     smartRepliesDelayDuration: 3_000
> )
> ```
>
> ![Smart replies over the bottom of the list: a Smart Replies title, a close button and three suggested replies](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListSmartReplies.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5f89b0569ded4deaa69779d60f92ed1a)
>
> Smart replies are fetched `smartRepliesDelayDuration` milliseconds (10 000 by default) after
> an incoming text, and only for a text containing one of `smartRepliesKeywords` when you set
> any. A tap on a starter or a smart reply puts its text in the composer, through the
> `.composeMessage` UI event; `onConversationStarterClick` and `onSmartReplyClick` replace
> that. Each panel has a style and a view slot — `conversationStarterView`,
> `smartRepliesView`, `conversationSummaryView` — that receives its state:
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     enableSmartReplies: true,
>     smartRepliesView: { state, onReply, onClose in
>         switch state {
>         case .loaded(let replies):
>             AnyView(HStack {
>                 ForEach(Array(replies.enumerated()), id: \.offset) { index, reply in
>                     Button(reply) { onReply(reply, index) }
>                 }
>                 Button("Close", action: onClose)
>             })
>         default:
>             AnyView(EmptyView())
>         }
>     }
> )
> ```
>
> The panels need the matching AI features enabled for your app. They are off in a chat with
> an AI agent, and only the main list — not a thread — fetches them.

> [tab] UIKit
>
> ```swift theme={null}
> messageList.enableConversationStarters = true
> messageList.enableSmartReplies = true
> // enableConversationSummary is on by default; the summary also needs startFromUnreadMessages
> messageList.startFromUnreadMessages = true
> messageList.set(smartRepliesKeywords: ["?", "when"]).set(smartRepliesDelayDuration: 3)
> ```
>
> The starters, smart replies and summary show one at a time, in a region of their own
> between the list and the footer: the summary first, then the starters, then smart replies.
> Your footer view stays. A tap puts the text in the composer.
> `set(smartRepliesDelayDuration:)` takes **seconds**.

### Chats With an AI Agent

A user whose role is `@agentic` is an AI agent.

> [tab] SwiftUI
>
> In a chat with one:
>
> * the empty chat shows the agent's greeting, introduction and suggested messages from its
>   metadata; a tap on a suggestion puts it in the composer;
> * the agent's reply streams in — a thinking shimmer, then text as it arrives, then the
>   finished reply with markdown and cards; a broken stream shows an error;
> * there is no long press, no swipe to reply and no reactions;
> * the list does not page back; `loadLastAgentConversation: true` opens the latest
>   conversation with the agent instead of the greeting.
>
> ![An empty chat with an AI agent named Nova: its avatar, the greeting Hi, I'm Nova, an introduction and four suggested-message chips](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListAgentGreeting.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=5859a4ed117d870e478fdafb75388c20)
>
> `hideAiAssistantSuggestedMessages` has no effect: the suggestions always show.

> [tab] UIKit
>
> In a chat with one, the list:
>
> * shows the agent's greeting and suggested messages in the empty chat —
>   `set(suggestedMessages:)` replaces them, `hideSuggestedMessages` hides them, and
>   `set(emptyChatAIGreetingView:)` replaces the whole view;
>
> * streams the agent's reply;
>
> * turns off swipe to reply and the three AI panels, and opens the latest conversation
>   only with `loadLastAgentConversation = true`.
>
> > [!WARNING]
> >
> > `set(user:)` with an agent turns swipe to reply and the AI panels off on the list, and a
> > later `set(user:)` with a person does not turn them back on. Use a new list for each
> > chat. `set(streamingSpeed:)` applies only after `set(user:)` — before it, it is stored
> > and never used.

***

## Message Information

**Info**, on your own messages, opens [message information](https://www.cometchat.com/docs/ui-kit/ios/v6/message-information.md)
in a sheet with a medium and a large detent.

> [tab] SwiftUI
>
> The sheet shows the message as a bubble, then who it reached and who read it. It gets the list's
> `bubbleFactories`, `onError` and its style's `messageInformationStyle`; `onMessageOptionClick`
> still fires. `hideMessageInfoOption` removes the option.
>
> ```swift theme={null}
> struct ChatWithStyledInfo: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         var style = CometChatMessageListStyle()
>         style.messageInformationStyle = CometChatMessageInformationStyle(backgroundHighlightColor: .yellow)
>         return CometChatMessageList(style: style, user: user)
>     }
> }
> ```
>
> The sheet formats mentions itself, so the list hands it no text formatters.

> [tab] UIKit
>
> The sheet is presented in a navigation controller with a grabber. The screen gets the list's
> templates, text formatters and `dateTimeFormatter`; its errors reach `set(onError:)` and the
> delegate; then `messageInformationConfiguration` is applied. `set(onMessageOptionClick:)` still
> fires; `hideMessageInfoOption` removes the option.
>
> ```swift theme={null}
> let configuration = MessageInformationConfiguration()
>     .set(titleText: "Delivery")
>     .set(emptyStateText: "Waiting for recipients")
> let list = CometChatMessageList()
>     .set(messageInformationConfiguration: configuration)
> ```

***

## Report

**Report**, on someone else's message, presents [the flag message](https://www.cometchat.com/docs/ui-kit/ios/v6/flag-message.md)
dialog full screen over the chat, opening and closing without animation. The dialog fetches
the app's flag reasons; the list flags the message when **Report** is tapped, closes the dialog
on success and shows its error line on failure. A tap on the scrim closes it.

> [tab] SwiftUI
>
> The dialog sits over a 40 % scrim, a Liquid Glass card on iOS 26. `onMessageOptionClick` still
> fires; `hideFlagOption` removes the option and `hideFlagRemarkInputField` the dialog's remark
> field. The list passes no style or texts — style the dialog with the theme and the
> `cometChatFlagMessage…` slot modifiers, which reach it:
>
> ```swift theme={null}
> struct ChatWithQuietReports: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         CometChatMessageList(user: user, hideFlagRemarkInputField: true)
>             .cometChatFlagMessageTitleView { title, onClose in
>                 HStack { Label(title, systemImage: "flag"); Spacer(); Button("Close", action: onClose) }
>             }
>     }
> }
> ```

> [tab] UIKit
>
> The dialog is presented `.overFullScreen` over a 40 % scrim, a Liquid Glass card on iOS 26;
> **Report** starts its spinner while the list flags the message.
> `set(onMessageOptionClick:)` still fires; `hideFlagMessageOption` removes the option.
>
> The list hands the dialog `hideFlagRemarkFeild` and `flagReasonLocalizer` and nothing
> else — style it through `CometChatFlagMessage.style`:
>
> ```swift theme={null}
> let list = CometChatMessageList()
> list.hideFlagRemarkFeild = true
> list.flagReasonLocalizer = { id in id == "impersonation" ? "Pretending to be someone" : "" }
> CometChatFlagMessage.style.reportButtonBackgroundColor = .systemRed
> ```

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Callback | Signature | Called |
> | - | - | - |
> | `onError` | `(CometChatError) -> Void` | while the error state shows — a failed older page or jump |
> | `onLoad` | `([BaseMessage]) -> Void` | while messages show, with the list's messages |
> | `onEmpty` | `() -> Void` | while the chat is empty |
> | `onMessageClick` | `(BaseMessage) -> Void` | a row was tapped — the bubble's own buttons excepted |
> | `onMessageLongClick` | `(BaseMessage) -> Void` | a long press opened the menu |
> | `onThreadRepliesClick` | `(BaseMessage) -> Void` | "N replies", or Reply in thread |
> | `onReactionClick` | `(BaseMessage, String) -> Void` | a chip — **instead of** the toggle |
> | `onReactionLongClick` | `(BaseMessage, String) -> Void` | a chip was long-pressed |
> | `onAddMoreReactionsClick` | `(BaseMessage) -> Void` | "+N" or the add button — **instead of** the emoji keyboard |
> | `onEmojiPickerClick` | `(BaseMessage) -> Void` | the menu's add-reaction button, the menu still up — **instead of** the emoji keyboard |
> | `onMessageOptionClick` | `(BaseMessage, String, String) -> Void` | every option, after its handling — not one with its own `onClick` |
> | `onQuickReactionClick` | `(BaseMessage, String) -> Void` | the menu's bar — **instead of** adding |
> | `onConversationStarterClick`, `onSmartReplyClick` | `(String, Int) -> Void` | a chip — **instead of** filling the composer |
> | `onMessagePrivately` | `(CometChatSDK.User) -> Void` | "Message privately", with the fetched sender |
> | `onMessageEdit`, `onMessageReply` | — | never called |
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     onError: { error in report(error) },
>     onMessagePrivately: { sender in openChat(with: sender) }
> )
> ```
>
> > [!WARNING]
> >
> > `onLoad`, `onEmpty` and `onError` are called **every time the view renders** while their
> > state holds, not once. Keep them idempotent. `onError` does not hear a failed delete,
> > reaction or translation.
>
> "Message privately" does nothing without `onMessagePrivately`: the sender is fetched and
> dropped.

> [tab] UIKit
>
> | Setter | Signature | Called |
> | - | - | - |
> | `set(onThreadRepliesClick:)` | `(BaseMessage, CometChatMessageTemplate) -> Void` | "N replies", or Reply in thread |
> | `set(onReactionClick:)` | `(ReactionCount, BaseMessage?) -> Void` | a chip — **instead of** the toggle |
> | `set(onReactionLongClick:)` | `(BaseMessage, String) -> Void` | a chip was long-pressed |
> | `set(onAddMoreReactionsClick:)` | `(BaseMessage) -> Void` | "+N" — **instead of** the emoji keyboard |
> | `set(onError:)` | `(CometChatException) -> Void` | once, when the error state shows |
> | `set(onLoad:)` | `([BaseMessage]) -> Void` | once per load |
> | `set(onEmpty:)` | `() -> Void` | once, when the chat is empty |
> | `set(onItemClick:)`, `set(onItemLongClick:)` | `(BaseMessage, Int) -> Void` | a row was tapped, or long-pressed |
> | `set(onMessageOptionClick:)` | `(BaseMessage, String, String) -> Void` | every option, after its handling |
> | `set(onQuickReactionClick:)` | `(BaseMessage, String) -> Void` | the menu's bar — **instead of** adding |
> | `set(onEmojiPickerClick:)` | `() -> Void` | the menu's add button, the menu still up — **instead of** the emoji keyboard |
> | `set(onMessagePrivately:)` | `(User) -> Void` | "Message privately", with the fetched sender |
> | `set(onReactionListItemClick:)` | `(Reaction, BaseMessage?) -> Void` | a row in the reaction list sheet was tapped |
>
> `onEmpty` is not called while `hideEmptyView` is set, nor `onError` while `hideErrorView`
> is. "Message privately" does nothing without `set(onMessagePrivately:)`.
>
> ```swift theme={null}
> messageList
>     .set(onError: { error in log(error) })
>     .set(onItemClick: { message, _ in track("tapped \(message.id)") })
> ```
>
> The callbacks are also available on `CometChatMessageListDelegate`, `@objc optional`. Both fire:
>
> ```swift theme={null}
> @MainActor final class ChatCoordinator: NSObject, CometChatMessageListDelegate {
>     func onThreadRepliesClick(message: BaseMessage) { openThread(message) }
>     func onError(error: NSError) { track(error.domain) }
> }
> ```

### Global Events

> [tab] SwiftUI
>
> The list emits:
>
> | Event | When |
> | - | - |
> | `.messageEdited(status: .inProgress)`, `.replyToMessage(status: .inProgress)` | Edit, Reply, or a swipe |
> | `.composeMessage(id:text:)` | a starter, smart reply or agent suggestion |
> | `.messageRead` | the newest message was marked read |
> | `.messagePinned`, `.messageUnpinned`, `.messageSaved`, `.messageUnsaved` | the server confirmed a pin or save |
> | `.conversationUpdated` | Mark as unread succeeded |
> | `.cardActionClicked` | a card action was tapped |
>
> See [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md) for the whole bus.

> [tab] UIKit
>
> The list announces `ccMessageEdited` and `ccReplyToMessage` in progress for Edit and Reply,
> and `ccComposeMessage` for AI suggestions; `ccMessageRead` when it marks a message read; and
> the pin and save events when the server confirms. See [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md).

### SDK Events (Real-Time, Automatic)

No wiring required — the list listens to the SDK and to the Kit's message, group and call
events for its chat, and updates itself.

***

## Functionality

> [tab] SwiftUI
>
> | Prop | Type | Default |
> | - | - | - |
> | `user` | `CometChatSDK.User?` | `nil` |
> | `group` | `CometChatSDK.Group?` | `nil` |
> | `parentMessage` | `BaseMessage?` | `nil` — the thread's root |
> | `parentMessageId` | `Int` | `-1` — deprecated; used only when `parentMessage` is `nil` |
> | `messagesRequestBuilder` | `(() -> MessagesRequest.MessageRequestBuilder)?` | `nil` |
> | `goToMessageId` | `Binding<MessageID?>?` | `nil` |
> | `store` | `MessageListStore?` | `nil` |
> | `scrollToBottomOnNewMessage` | `Bool` | `true` |
> | `swipeToReplyEnabled` | `Bool` | `true` |
> | `autoFetch` | `Bool` | `true` |
> | `startFromUnreadMessages` | `Bool` | `false` |
> | `unreadMessageThreshold` | `Int` | `30` |
> | `disableSoundForMessages` | `Bool` | `false` |
> | `customSoundForMessages` | `URL?` | `nil` |
> | `disableReceipt` | `Bool` | `false` |
> | `enableMultipleAttachments` | `Bool` | `true` |
> | `timeStampAlignment` | `TimeStampAlignment` | `.bottom` |
> | `messageAlignment` | `MessageListAlignment` | `.standard` |
> | `loadLastAgentConversation` | `Bool` | `false` |
> | `policy` | `MessageListPolicy` | `.default` |
> | `optionsPolicy` | `MessageOptionsPolicy` | `.default` |
> | `quickReactions` | `[String]` | 👍 ❤️ 😂 😮 😢 🙏 |
> | `enableConversationStarter`, `enableSmartReplies`, `enableConversationSummary` | `Bool` | `false` |
> | `smartRepliesKeywords` | `[String]` | `[]` |
> | `smartRepliesDelayDuration` | `Int?` (ms) | `nil` — 10 000 |
> | `bubbleFactories` | `[any BubbleFactory]` | none — registered after the built-ins; the last wins per `MessageKind` |
> | `textFormatters` | `[any CometChatTextFormatter]?` | `nil` |
> | `disableMentionAll` | `Bool` | `false` |
> | `mentionAllLabelId`, `mentionAllLabel` | `String?` | `nil` |
> | `timeFormat`, `dateFormat` | `String?` | `nil` |
> | `dateTimeFormatter` | `(any CometChatDateTimeFormatter)?` | `nil` |
> | `style` | `CometChatMessageListStyle` | `.init()` |
> | `conversationStarterStyle`, `smartRepliesStyle`, `conversationSummaryStyle` | `CometChatAIConversationStarterStyle`, `CometChatAISmartRepliesStyle`, `CometChatAIConversationSummaryStyle` | the theme's |
> | `imageSource` | `any ImageSource` | the shared cached loader |
>
> Visibility:
>
> | Parameter | Default | Hides |
> | - | - | - |
> | `hideLoadingState`, `hideEmptyState`, `hideErrorState` | `false` | a state view |
> | `hideAvatar` | `false` | the avatars |
> | `hideReactions` | `false` | the reaction chips |
> | `hideGroupActionMessages` | `false` | group actions — calls stay |
> | `hideDateSeparator`, `hideStickyDate`, `hideNewMessagesSeparator` | `false` | a separator |
> | `hideModerationView` | `false` | the notice under a disapproved message |
> | the 13 `hide…Option` flags | `false` | a [menu option](#hiding-options) |
> | `hideReceipts`, `hideAiAssistantSuggestedMessages` | `false` | nothing — no effect |
> | `hideFlagRemarkInputField` | `false` | the report dialog's remark field |
>
> The same elements can be hidden for a whole subtree — it can hide more than a list's own
> flags, never less. `.newMessageIndicator` has no parameter:
>
> ```swift theme={null}
> MyAppRoot()
>     .cometChatMessageListHidden([.stickyDate, .avatar, .newMessageIndicator, .translateMessageOption])
> ```

> [tab] UIKit
>
> | Property | Type | Default |
> | - | - | - |
> | `hideReceipts`, `hideDateSeparator`, `hideUnreadSeparator` | `Bool` | `false` |
> | `hideAvatar` | `Bool` | `false` — see [Rows](#rows) |
> | `hideLoadingView`, `hideEmptyView`, `hideErrorView` | `Bool` | `false` |
> | `hideHeaderView`, `hideFooterView` | `Bool` | `false` |
> | `hideGroupActionMessages`, `hideNewMessageIndicator`, `hideReactions`, `hideModerationStatus` | `Bool` | `false` |
> | the twelve `hide…Option` flags | `Bool` | `false` |
> | `showMarkAsUnreadOption` | `Bool` | `false` |
> | `quickReactions` | `[String]` | 👍 ❤️ 😂 😮 😢 🙏 |
> | `scrollToBottomOnNewMessages` | `Bool` | `true` |
> | `disableSwipeToReply`, `startFromUnreadMessages`, `disableSoundForMessages` | `Bool` | `false` |
> | `messageAlignment` | `MessageListAlignment` | `.standard` |
> | `disableMentionAll` | `Bool` | `false` |
> | `enableConversationStarters`, `enableSmartReplies`, `loadLastAgentConversation` | `Bool` | `false` |
> | `enableConversationSummary` | `Bool` | `true` — asked for only with `startFromUnreadMessages` |
> | `hideSuggestedMessages` | `Bool` | `false` |
> | `emptyTitleText`, `emptySubtitleText` | `String?` | `nil` — the default copy |
> | `errorTitleText`, `errorSubtitleText` | `String` | "Oops!", "Looks like something went wrong…" |
> | `dateTimeFormatter` | `CometChatDateTimeFormatter?` | `nil` |
> | `style` | `MessageListStyle` | a copy of `CometChatMessageList.style` |
> | `emojiKeyboardStyle` | `EmojiKeyboardStyle` | a copy of `CometChatMessageList.emojiKeyboardStyle` |
> | `theme` | `CometChatUIKitTheme` | `.shared` |
> | `delegate` | `CometChatMessageListDelegate?` | `nil` |
>
> | Method | Does |
> | - | - |
> | `set(user:parentMessage:)`, `set(group:parentMessage:)` | gives the list its chat, and a thread's root message |
> | `set(messagesRequestBuilder:)` | replaces the request — call it before `set(user:)` |
> | `set(store:)` | renders another `MessageListStore` |
> | `set(templates:)`, `add(templates:)` | replaces or adds [templates](#your-own-bubble) |
> | `set(customSoundForMessages:)` | the sound for incoming messages, a `URL` |
> | `set(enableMultipleAttachments:)` | switches the attachment bubbles, default `true` |
> | `set(smartRepliesKeywords:)`, `set(smartRepliesDelayDuration:)` | the smart replies' keywords, and their delay in seconds — 10 by default |
> | `set(suggestedMessages:)`, `set(emptyChatAIGreetingView:)`, `set(streamingSpeed:)` | an AI agent's chat: its suggestions, its greeting view, its streaming speed in ms |
> | `setMentionAllLabel(_:_:)` | renames mention-all |
> | `connect()`, `disconnect()` | adds or removes the SDK and Kit listeners for the current chat |
> | `add(message:)`, `update(message:)`, `remove(message:)` | changes a row locally |
> | `delete(message:)` | deletes on the server, then updates the row |
> | `clearList()` | empties the list |
> | `scrollToBottom(isAnimated:)` | the newest row — fetching the latest page when newer pages are not loaded |
> | `scrollToLastVisibleCell()` | the last visible row |
> | `goToMessage(withId:highlight:)` | jumps to a message |
> | `isEmpty()` | whether the list holds no messages |
>
> The methods return `Void`.
>
> ```swift theme={null}
> messageList.disconnect()   // the screen went off
> messageList.connect()      // and came back
> ```

***

## Custom View Slots

### Row Slots

> [tab] SwiftUI
>
> Every region of every row can be replaced. Each slot is a `MessageRowSlot` —
> `(ChatMessage, MessageAlignment) -> AnyView`:
>
> | Slot | Region |
> | - | - |
> | `leadingView` | the avatar |
> | `headerView` | the sender's name above the bubble |
> | `replyView` | the quoted message inside the bubble |
> | `contentView` | the payload, for **every** kind |
> | `bottomView` | under the payload, inside the bubble — the moderation notice |
> | `statusInfoView` | the time and receipt line |
> | `threadView` | "N replies" under the bubble |
> | `footerView` | the reactions under the bubble |
>
> A slot outranks a factory's region, which outranks the list's default.
>
> ```swift theme={null}
> CometChatMessageList(
>     group: group,
>     headerView: { message, _ in
>         AnyView(Text(message.sender.name).font(.caption.bold()).foregroundStyle(.indigo))
>     },
>     statusInfoView: { message, alignment in
>         AnyView(Text(message.sentAt, style: .time).font(.caption2)
>             .frame(maxWidth: .infinity, alignment: alignment == .outgoing ? .trailing : .leading))
>     }
> )
> ```
>
> Every slot is also a modifier, for every list in a subtree. An initialiser argument wins:
>
> ```swift theme={null}
> MyAppRoot()
>     .cometChatMessageLeadingView { message, _ in
>         Circle().fill(.indigo).frame(width: 32, height: 32)
>             .overlay(Text(message.sender.name.prefix(1)).foregroundStyle(.white))
>     }
> ```
>
> > [!NOTE]
> >
> > With `messageAlignment: .leftAligned`, a slot is told the **sender's** alignment —
> > `.outgoing` for your own messages — although the row is drawn on the leading side.

> [tab] UIKit
>
> Rows are customised with [templates](#your-own-bubble), and with the override points under
> [Subclassing](#subclassing).

### State and List Views

> [tab] SwiftUI
>
> | Slot | Receives | Replaces |
> | - | - | - |
> | `loadingView` | — | the shimmer |
> | `emptyView` | — | the empty state |
> | `errorView` | `retry` | the error state |
> | `newMessageIndicatorView` | the count, and the tap that scrolls down | the new-message indicator |
> | `newMessagesSeparatorView` | — | the new-messages separator |
> | `listHeaderView` | — | adds a fixed view above the list |
> | `listFooterView` | — | adds a fixed view below the list |
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     emptyView: { AnyView(Text("Say hello 👋").font(.title3)) },
>     errorView: { retry in AnyView(Button("Try again", action: retry)) },
>     newMessageIndicatorView: { count, scrollToBottom in
>         AnyView(Button("\(count) new", action: scrollToBottom).buttonStyle(.borderedProminent))
>     }
> )
> ```
>
> The header and footer do not scroll with the messages. Each slot has a modifier too —
> `.cometChatMessageListEmptyView { … }` and so on.

> [tab] UIKit
>
> | Setter | Replaces |
> | - | - |
> | `set(loadingView:)`, `set(emptyView:)`, `set(errorView:)` | a state view |
> | `set(headerView:)` | adds a fixed view above the list — `hideHeaderView` hides it |
> | `set(footerView:)` | adds a fixed view below the list — `hideFooterView` hides it |
> | `set(newMessageIndicatorView:)` | nothing — the view is kept and not shown |
>
> ```swift theme={null}
> let empty = UILabel()
> empty.text = "Say hello 👋"
> empty.textAlignment = .center
> messageList.set(emptyView: empty)
> ```

***

## Formatting

> [tab] SwiftUI
>
> | Parameter | Formats |
> | - | - |
> | `timeFormat` | the time on each status line — a `DateFormatter` pattern; by default the device's 12- or 24-hour time |
> | `dateFormat` | date separators older than yesterday; Today and Yesterday stay words |
> | `dateTimeFormatter` | both, and wins over the patterns: its `time`, `today`, `yesterday` and `otherDays` |
>
> ```swift theme={null}
> struct ShortDates: CometChatDateTimeFormatter {
>     func otherDays(_ date: Date) -> String? { date.formatted(.dateTime.day().month(.abbreviated)) }
> }
>
> struct ChatScreen: View {
>     let user: CometChatSDK.User
>
>     var body: some View {
>         CometChatMessageList(user: user, timeFormat: "HH:mm", dateTimeFormatter: ShortDates())
>     }
> }
> ```

> [tab] UIKit
>
> | Setter | Signature | Formats |
> | - | - | - |
> | `set(datePattern:)` | `(Int?) -> String` | the date separators, when no `dateSeparatorPattern` is set |
> | `set(timePattern:)` | `(Int?) -> String` | the time under each message |
> | `set(dateSeparatorPattern:)` | `(Int?) -> String` | the date separators |
> | `dateTimeFormatter` | `CometChatDateTimeFormatter` | the date and time |
> | `set(textFormatters:)` | `[any CometChatTextFormatter]` | the text of a message |

### Mentions

A tap on a user mention in a text message opens that user's chat: the list raises the
`openChat` UI event with that user. Push the chat where your app navigates:

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatMessageList(user: user)
>     .onCometChatOpenChat { user, _ in
>         if let user { openChat(with: user) }
>     }
> ```
>
> A `TextBubbleFactory(onMentionClick:)` you register still gets the tap, first. Mention-all opens
> nothing.
>
> Mentions are drawn by a mentions formatter. With `textFormatters: nil`, the default, the
> list makes one — `disableMentionAll` turns off mention-all, and `mentionAllLabelId` with
> `mentionAllLabel` rename it:
>
> ```swift theme={null}
> CometChatMessageList(group: group, mentionAllLabelId: "channel", mentionAllLabel: "channel")
> ```
>
> > [!NOTE]
> >
> > Copy and Share put out the **raw** text — a mention stays `<@uid:…>` — unless you pass
> > `textFormatters`.

> [tab] UIKit
>
> ```swift theme={null}
> final class ChatsRouter: UIViewController, CometChatUIEventListener {
>
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         CometChatUIEvents.addListener("chats-router", self)
>     }
>
>     func openChat(user: User?, group: Group?) {
>         guard let user else { return }
>         let chat = UIViewController()   // your messages screen for `user`
>         chat.title = user.name
>         navigationController?.pushViewController(chat, animated: true)
>     }
> }
> ```
>
> A mentions formatter you pass with `set(textFormatters:)` hears the tap first — its
> `onMentionClick` gets the mentioned `User`, `onMentionAllClick` a mention-all, which opens
> nothing.

***

## Menu Options

A long press on a message opens its menu: a bar of quick reactions and the options. Up to
six options show at once; with more, a seventh row, **More**, expands the rest in place — it
stays as the header of the same card, and tapping it again folds them back.

> [tab] SwiftUI
>
> The quick-reactions bar sits above the message, and the options below it.
>
> ![The option menu over a long-pressed incoming text: a bar of six quick reactions above it, and below it Reply, Reply In Thread, Subscribe to thread, Copy, Share, Translate and More](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListMenu.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=034e7e1240d049d60e97c8c4975b3b35)
>
> There is no long press on group actions, calls, or an AI agent's replies, nor on a message
> that is still sending or was deleted. In a chat with an AI agent there is none at all.

> [tab] UIKit
>
> The menu shows the message over a dimmed page, a bar of quick reactions with an add button, and a
> card of options. Delete is in the error colour.
>
> There is no long press on group actions, calls or an AI agent's replies, nor on a message
> that is still sending or was deleted.

| Kind | Options, in order |
| - | - |
| text | Reply, Reply in thread, Thread subscription, Copy, Edit, Delete, Share, Translate, Mark as unread, Pin / Unpin, Save / Unsave, Info, Report, Message privately |
| image, video, audio, file | the same, without Copy and Translate |
| sticker, poll, document, whiteboard, card, custom | Reply, Reply in thread, Thread subscription, Delete, Mark as unread, Pin / Unpin, Save / Unsave, Info, Report, Message privately |
| meeting | the same, without Report |

> [tab] SwiftUI
>
> Each option keeps its rules:
>
> | Option | Offered | Does |
> | - | - | - |
> | Reply | always | the composer quotes the message (`.replyToMessage(status: .inProgress)`) |
> | Reply in thread | not in a thread, not on a reply | calls `onThreadRepliesClick` |
> | Thread subscription | not on actions, calls or interactive messages; not when your app turned subscriptions off | [subscribes or unsubscribes](#thread-subscription) |
> | Copy | text | copies the text |
> | Edit | your own message; media only with a caption | the composer edits it (`.messageEdited(status: .inProgress)`) |
> | Delete | your own message, or you are a group's admin, moderator or owner | asks, then deletes on the server |
> | Share | text and media | the share sheet — the text, or the file |
> | Translate | text | translates into the device's language |
> | Mark as unread | others' messages, not in a thread | moves the new-messages separator to the message |
> | Pin / Unpin, Save / Unsave | when your app's pin or save feature is on | [pins or saves](#pin-and-save) |
> | Info | your own message | opens [message information](#message-information) |
> | Report | others' messages | opens the [flag message](#report) |
> | Message privately | others' messages in a group | fetches the sender for `onMessagePrivately` |
>
> A message the moderator disapproved keeps only Copy, Delete and Translate, and has no quick
> reactions.
>
> > [!NOTE]
> >
> > Delete asks first, in a system alert. The row changes only when the server confirms; a
> > failed delete changes nothing and reports nothing. Translate draws the translation under
> > the message's text, below a separator, with a "Translated message" caption.
>
> Every chosen option ends at `onMessageOptionClick`, after the built-in handling, with the
> option's id and title:
>
> ```swift theme={null}
> CometChatMessageList(
>     group: group,
>     onMessageOptionClick: { message, id, title in
>         if id == MessageOptionID.report.rawValue { reportMessage(message) }
>     }
> )
> ```

> [tab] UIKit
>
> Edit only on your own message (media with a caption); Delete on yours, or as a group's admin,
> moderator or owner; Report on others'; Info on yours; Message privately on others' in a group;
> Reply in thread and Mark as unread not in a thread; Pin and Save only when your app has them
> on. A disapproved message keeps Copy, Delete and Translate.
>
> | Option | Does |
> | - | - |
> | Reply, Edit | the composer replies or edits, through the Kit's events |
> | Copy | copies the text |
> | Delete | asks in an alert, then deletes on the server |
> | Share | the share sheet — the text, or the file's link |
> | Translate | translates into the device's language, drawn under the text |
> | Mark as unread | moves the unread separator to the message |
> | Reply in thread | `set(onThreadRepliesClick:)` |
> | Thread subscription | [subscribes or unsubscribes](#thread-subscription) |
> | Pin / Unpin, Save / Unsave | [pins or saves](#pin-and-save) |
> | Message privately | fetches the sender for `set(onMessagePrivately:)` |
> | Info | presents [message information](#message-information) |
> | Report | presents the [flag message](#report) |

### Hiding Options

> [tab] SwiftUI
>
> Each built-in has a flag: `hideReplyOption`, `hideReplyInThreadOption`,
> `hideThreadSubscriptionOption`, `hideCopyMessageOption`, `hideEditMessageOption`,
> `hideDeleteMessageOption`, `hideShareMessageOption`, `hideTranslateMessageOption`,
> `hideMarkAsUnreadOption`, `hideMessageInfoOption`, `hideFlagOption` (Report),
> `hideMessagePrivatelyOption`, and `hideMessageReactionOption` (the quick reactions).
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     hideReplyInThreadOption: true,
>     hideMessageInfoOption: true,
>     hideTranslateMessageOption: true,
>     hideFlagOption: true
> )
> ```
>
> `hideReplyOption` also hides an option of yours with the id `reply_to_message`.
> `hideFlagRemarkInputField` hides the report dialog's remark field.

> [tab] UIKit
>
> **Mark as unread** is hidden until `showMarkAsUnreadOption = true`. The other options have hide
> flags:
>
> ```swift theme={null}
> messageList.hideReplyInThreadOption = true
> messageList.hideTranslateMessageOption = true
> messageList.hideFlagMessageOption = true
> messageList.showMarkAsUnreadOption = true
> ```
>
> `hideReactionOption` hides the quick reactions, `hideFlagMessageOption` Report and
> `hideReplyMessageOption` Reply. `hideFlagRemarkFeild` hides the report dialog's remark field.

### Your Own Options

> [tab] SwiftUI
>
> `addOptions` appends options after the built-ins. `options` **replaces** the menu when it
> returns non-`nil`, and then `addOptions` is not asked. Neither is filtered by the hide flags.
> An option with its own `onClick` runs that **instead of** the list's handling, and does not
> reach `onMessageOptionClick`:
>
> ```swift theme={null}
> CometChatMessageList(
>     group: group,
>     addOptions: { message in
>         [MessageOption(id: "forward", title: "Forward", icon: .system("arrowshape.turn.up.right"),
>                        onClick: { forward(message) })]
>     }
> )
> ```
>
> To change who may edit, delete, report, see Info or message privately, pass an
> `optionsPolicy`:
>
> ```swift theme={null}
> let rules = MessageOptionsPolicy(
>     canEdit: { message, context in context.isMine(message) && message.kind == .text },
>     canDelete: { message, context in context.isMine(message) }
> )
> CometChatMessageList(group: group, optionsPolicy: rules)
> ```

> [tab] UIKit
>
> `set(addOptions:)` appends; `set(options:)` **replaces** the menu when it returns non-`nil`
> — before a template's `options`. Neither is filtered by the hide flags. Every option, built
> in or yours, ends at `set(onMessageOptionClick:)` after the list's own handling, with its
> id and title:
>
> ```swift theme={null}
> messageList
>     .set(addOptions: { _ in
>         [CometChatMessageOption(id: "forward", title: "Forward",
>                                 icon: UIImage(systemName: "arrowshape.turn.up.right"))]
>     })
>     .set(onMessageOptionClick: { message, id, _ in
>         if id == "forward" { forward(message) }
>         if id == "message_information" { showMessageInfo(message) }
>     })
> ```
>
> > [!WARNING]
> >
> > An option's own `onItemClick` is **never called** — handle every option in
> > `set(onMessageOptionClick:)`. Only the built-in Delete turns red.

### Quick Reactions

> [tab] SwiftUI
>
> The bar shows `quickReactions` — 👍 ❤️ 😂 😮 😢 🙏 by default. A tap **adds** that reaction;
> `onQuickReactionClick` replaces that. Tapping a reaction you already gave adds it again
> rather than removing it. An empty list shows the popup's own five.

> [tab] UIKit
>
> `quickReactions` — 👍 ❤️ 😂 😮 😢 🙏 by default — fill the bar. A tap adds the reaction;
> `set(onQuickReactionClick:)` replaces that. An empty list shows the popup's own five. The
> add button closes the menu and opens the [emoji keyboard](https://www.cometchat.com/docs/ui-kit/ios/v6/emoji-keyboard.md)
> in a 400 pt sheet, which rises once the menu has gone. `set(onEmojiPickerClick:)` replaces the
> keyboard; it is called **while the menu is still on screen**, before the menu closes — present
> your own picker from the top presented controller, or after the menu has gone.

***

## Advanced Methods

### Store Access

> [tab] SwiftUI
>
> Every list has a `MessageListStore`. Pass your own to share it, or to render fixed state
> with no session — a seeded store fetches, listens and sends nothing:
>
> ```swift theme={null}
> #Preview {
>     CometChatMessageList(
>         store: MessageListStore(seeded: .populated(ChatMessage.sampleEntries, hasOlder: false, hasNewer: false))
>     )
> }
> ```
>
> `MessageListPolicy` holds the list's rules:
>
> | Hook | Decides |
> | - | - |
> | `swipeToReplyEligible` | which rows can be swiped |
> | `shouldPlaySound` | which incoming messages play the sound |
> | `shouldShowInList` | which live messages are shown |
> | `isThreadedMessage` | which live messages count as thread replies |
> | `countsAsUnread` | which messages count for the new-messages separator |
>
> ```swift theme={null}
> let quiet = MessageListPolicy(shouldPlaySound: { message in message.kind == .text })
> CometChatMessageList(user: user, policy: quiet)
> ```
>
> > [!NOTE]
> >
> > The behaviour flags — `disableReceipt`, `startFromUnreadMessages`,
> > `unreadMessageThreshold`, the sound flags, the AI flags and `loadLastAgentConversation`
> > — reach the store only when the user, group or `goToMessageId` changes. Changing one on
> > a list already showing that chat has no effect.

> [tab] UIKit
>
> `store` is the `MessageListStore` behind the list. `set(store:)` renders another one — a
> seeded store has fixed rows and fetches, listens and sends nothing:
>
> ```swift theme={null}
> let preview = CometChatMessageList()
> preview.set(store: MessageListStore(seeded: .populated(ChatMessage.sampleEntries, hasOlder: false, hasNewer: false),
>                                     toolkit: .uiKit))
> ```

### Subclassing

> [tab] SwiftUI
>
> `CometChatMessageList` is a `View` struct. Customise it with its parameters, slots, modifiers,
> store and policies.

> [tab] UIKit
>
> The class is `open`. Its override points:
>
> | Method | Called |
> | - | - |
> | `buildUI()` | once, to build the header container, the table and the footer container |
> | `setupStyle()` | when the style or theme changes |
> | `reload()` | after a setting changed, to redraw the rows |
> | `setupViewModel()` | once, to bind the store |
> | `handleThemeModeChange()` | on a light / dark change |
> | `showLoadingView()`, `showEmptyView()`, `showErrorView()` and their `remove…` | the state views |
> | `showTopSpinner()`, `hideTopSpinner()` | the older-page spinner |
> | `showNewMessageIndicator()` | the indicator |
> | `buildMessageFooterView(on:message:)` | a row's status line |
> | `addMessageReplyPreview(on:message:)` | a row's quote |
> | `addThreadedRepliesView(on:message:)` | a row's "N replies" |
> | `addModerationView(on:message:)` | a row's moderation notice |
> | `addAIActionBarView(on:message:)` | an AI reply's copy button |
>
> Each row is a `CometChatMessageBubble` cell with public subviews, and `set(statusInfoView:)`,
> `set(replyView:)`, `set(bottomView:)` and the others to fill them. Call `super` unless you
> replace the behaviour on purpose:
>
> ```swift theme={null}
> final class QuietStatusList: CometChatMessageList {
>     override func buildMessageFooterView(on cell: CometChatMessageBubble, message: BaseMessage?) {
>         guard let message else { return }
>         let time = UILabel()
>         time.font = .preferredFont(forTextStyle: .caption2)
>         time.text = Date(timeIntervalSince1970: TimeInterval(message.sentAt)).formatted(date: .omitted, time: .shortened)
>         cell.set(statusInfoView: time)
>     }
>
>     override func setupStyle() {
>         super.setupStyle()
>         tableView.separatorStyle = .none
>     }
> }
> ```

### Objective-C

In the UIKit toolkit:

The list is `@objc`. Fluent setters take Swift's `set(user:)` as `setWithUser:`:

```objc theme={null}
CometChatMessageList *list = [[CometChatMessageList alloc] init];
[list setWithUser:user parentMessage:nil];
list.hideReceipts = YES;
list.showMarkAsUnreadOption = YES;
[list setOnError:^(CometChatException *error) { NSLog(@"%@", error.errorCode); }];

CometChatMessageTemplate *template =
    [[CometChatMessageTemplate alloc] initWithCategory:@"custom" type:@"location"
        contentView:nil bubbleView:nil headerView:nil footerView:nil
        bottomView:nil options:nil statusInfoView:nil replyView:nil];
[list addWithTemplates:@[template]];
```

`CometChatMessageTemplate` is a class, so Objective-C can build one. **Swift only**:
`store` / `set(store:)`, `quickReactions`, `dateTimeFormatter`, `set(textFormatters:)`, the three
pattern setters, and the four state-copy properties (`emptyTitleText`, `emptySubtitleText`,
`errorTitleText`, `errorSubtitleText`).

***

## Style

> [tab] SwiftUI
>
> `CometChatMessageListStyle` is sparse: set only what you change, and everything else
> follows the theme.
>
> ```swift theme={null}
> var outgoing = MessageBubbleStyle(backgroundColor: .indigo, cornerRadius: 16)
> var text = TextBubbleStyle()
> text.textColor = .white
> text.linkColor = .yellow
> outgoing.textBubbleStyle = text
>
> var style = CometChatMessageListStyle()
> style.outgoingBubbleStyle = outgoing
> style.backgroundColor = Color(.systemGroupedBackground)
>
> CometChatMessageList(style: style, user: user)
> ```
>
> | Property | Styles |
> | - | - |
> | `backgroundColor` | the list — `background3` (`background2` in dark), on every path; the Liquid Glass header and composer sample it |
> | `incomingBubbleStyle`, `outgoingBubbleStyle`, `actionBubbleStyle` | a `MessageBubbleStyle` per side: container colour, corner, border, sender name, time and text |
> | `dateSeparatorStyle`, `unreadSeparatorStyle` | the separators |
> | `incomingMessagePreviewStyle`, `outgoingMessagePreviewStyle` | the quote on others' and on your messages |
> | `reactionStyle` | the chips and the add button |
> | `threadIndicatorStyle` | "N replies" |
> | `newMessageIndicatorStyle` | the new-message indicator |
> | `emptyStateStyle`, `errorStateStyle` | the state views |
>
> Each `MessageBubbleStyle` also carries a content style per kind: `textBubbleStyle`,
> `imageBubbleStyle`, `videoBubbleStyle`, `fileBubbleStyle`, `audioBubbleStyle` (the voice
> note), `audiosBubbleStyle`, `meetCallBubbleStyle`, `pollBubbleStyle`,
> `collaborativeBubbleStyle`, `deleteBubbleStyle` and, on `actionBubbleStyle`,
> `callActionBubbleStyle`. A factory's own `style(for:)` wins over the list's.
>
> > [!NOTE]
> >
> > `aiAssistantBubbleStyle` and `moderationViewStyle` exist but are not applied: AI replies
> > take the incoming style, and the moderation notice its fixed colours.
>
> For every list — and every other component — set the theme at the root:
>
> ```swift theme={null}
> MyApp()
>     .cometChatTheme(brandTheme)
> ```

> [tab] UIKit
>
> **Style hierarchy**
>
> ```
> instance style  >  CometChatMessageList.style  >  theme  >  Kit default
> ```
>
> **Global level.** The static style is the default every list created **afterwards** copies — set
> it before creating lists:
>
> ```swift theme={null}
> CometChatMessageList.style.messageBubbleStyle.outgoing.backgroundColor = .systemIndigo
> CometChatUIKitTheme.shared.setBrandColor(.systemIndigo)
> ```
>
> **Instance level.** Assigning `style` applies it and redraws the rows:
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.backgroundColor = .systemGroupedBackground
> style.messageBubbleStyle.outgoing.backgroundColor = .systemIndigo
> style.messageBubbleStyle.outgoing.textColor = .white
> style.messageBubbleStyle.incoming.cornerRadius = 16
> style.dateSeparatorStyle.textColor = .secondaryLabel
> messageList.style = style
> ```
>
> Unset colours and fonts follow `CometChatUIKitTheme`. A corner radius or border width left at
> `-1` takes the Kit's default.
>
> | Property | Styles |
> | - | - |
> | `backgroundColor`, `borderColor`, `borderWidth`, `cornerRadius` | the list — `background3` (`background2` in dark) |
> | `emptyState…`, `errorState…` — title and subtitle colour and font | the state views |
> | `threadedMessageImage` | the "N replies" glyph |
> | `messageBubbleStyle.incoming`, `.outgoing` | a `MessageBubbleStyle` per side: background, border, corner; header, time and text colour and font; link colour; thread indicator; link-preview and separator strokes; the tombstone |
> | `actionBubbleStyle` | group actions |
> | `callActionBubbleStyle` | calls, missed calls apart |
> | `dateSeparatorStyle` | the date pill and the sticky date |
> | `unreadSeparatorStyle` | the unread separator |
> | `newMessageIndicatorStyle` | the indicator and its badge |

***

## Next Steps

> [card] [Message Composer](https://www.cometchat.com/docs/ui-kit/ios/v6/message-composer.md)
>
> The input the list's Edit, Reply and smart replies fill

> [card] [Message Header](https://www.cometchat.com/docs/ui-kit/ios/v6/message-header.md)
>
> The bar above the list

> [card] [Events](https://www.cometchat.com/docs/ui-kit/ios/v6/events.md)
>
> What the list listens to and announces

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> The tokens every bubble's default comes from


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.