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

# Building A Conversation List + Message View

> Build a conversation list that opens a full-screen chat, with the CometChat iOS UI Kit v6 SwiftUI or UIKit toolkit.

> [accordion] AI Integration Quick Reference
>
> | Field | Value |
> | - | - |
> | Components | `CometChatConversations`, `CometChatMessageHeader`, `CometChatMessageList`, `CometChatMessageComposer` |
> | Layout | Sequential navigation — conversation list → full-screen chat |
> | SwiftUI | `NavigationStack` + `navigationDestination(item:)`; `CometChatConversations(embedsNavigationStack: false, onItemClick:)` |
> | UIKit | `UINavigationController`; `CometChatConversations.set(onItemClick:)` pushes a `UIViewController` hosting the three message views |
> | Prerequisite | Complete [SwiftUI](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-swiftui.md) or [UIKit](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-uikit.md) Getting Started Steps 1–3 first |
> | Pattern | WhatsApp, Slack, Telegram |

This guide builds a sequential chat layout — the conversation list is the entry point, and a tap opens a
full-screen chat.

It assumes you have completed the Getting Started guide for your toolkit (project created, package added,
`initialize` and `login` working).

***

## What You're Building

Three parts working together:

1. **Conversation list** — every conversation of the logged-in user, one-to-one and group
2. **Message header** — the user's or group's name, avatar, and status or member count
3. **Message list + composer** — the chat history, live, and the input

> [tab] SwiftUI
>
> A `NavigationStack` holds the conversation list. A tap stores the chat in `@State`, and
> `navigationDestination(item:)` pushes the chat screen.

> [tab] UIKit
>
> A `UINavigationController` holds the conversation list — a `CometChatConversations` view controller. A
> tap pushes a view controller that lays out the header, the list and the composer.

![The conversation list this guide starts from](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-none.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=52632d9b876614d3adc2ff672fa4795f)

***

## Step 1: Set Up the Conversation List

> [tab] SwiftUI
>
> Create `ChatsView.swift`. `CometChatConversations` brings its own `NavigationStack` unless you pass
> `embedsNavigationStack: false` — pass it, because the chat is pushed onto yours:
>
> ```swift ChatsView.swift theme={null}
> import SwiftUI
> import CometChatSwiftUI
> import CometChatSDK
>
> struct ChatsView: View {
>     @State private var openChat: ChatTarget?
>
>     var body: some View {
>         NavigationStack {
>             CometChatConversations(
>                 embedsNavigationStack: false,
>                 onItemClick: { conversation in
>                     openChat = ChatTarget(conversation)
>                 }
>             )
>             .navigationDestination(item: $openChat) { chat in
>                 MessageView(user: chat.user, group: chat.group)
>             }
>         }
>     }
> }
>
> /// Who a chat is with. A conversation is with a `User` or a `Group`.
> struct ChatTarget: Hashable {
>     let user: CometChatSDK.User?
>     let group: CometChatSDK.Group?
>
>     init?(_ conversation: CometChatSDK.Conversation) {
>         user = conversation.conversationWith as? CometChatSDK.User
>         group = conversation.conversationWith as? CometChatSDK.Group
>         if user == nil && group == nil { return nil }
>     }
> }
> ```

> [tab] UIKit
>
> Create `ChatsViewController.swift`. `CometChatConversations` is an `open` view controller, so subclass it
> and push the chat from its item click:
>
> ```swift ChatsViewController.swift theme={null}
> import UIKit
> import CometChatUIKit
> import CometChatSDK
>
> final class ChatsViewController: CometChatConversations {
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         set(onItemClick: { [weak self] conversation, _ in
>             let chat = MessageViewController(user: conversation.conversationWith as? CometChatSDK.User,
>                                              group: conversation.conversationWith as? CometChatSDK.Group)
>             self?.navigationController?.pushViewController(chat, animated: true)
>         })
>     }
> }
> ```

The list shows the system large-title navigation bar — "Chats", with a search field — which is Liquid
Glass on iOS 26 and opaque on earlier versions.

***

## Step 2: Set Up the Message Screen

> [tab] SwiftUI
>
> Create `MessageView.swift`. 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.
>
> 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 title and
> search field in it. A bar that stays cross-fades to the list's. SwiftUI drops a bar that has nothing in
> it, so ask for it by name, and take its height back off the screen's safe area so the header keeps its
> place under the status bar. Call `dismiss` from the header's back button — it never pops by itself:
>
> ```swift MessageView.swift theme={null}
> import SwiftUI
> import CometChatSwiftUI
> import CometChatSDK
>
> struct MessageView: View {
>     let user: CometChatSDK.User?
>     let group: CometChatSDK.Group?
>     @Environment(\.dismiss) private var dismiss
>
>     var body: some View {
>         CometChatMessageList(user: user, group: group)
>             .modifier(ChatBars(
>                 header: CometChatMessageHeader(user: user, group: group, onBack: { dismiss() }),
>                 composer: CometChatMessageComposer(user: user, group: group)))
>             .modifier(ClearNavigationBar())
>             .toolbar(.hidden, for: .tabBar)
>     }
> }
>
> /// The navigation bar kept, empty and clear, over the header.
> struct ClearNavigationBar: ViewModifier {
>     func body(content: Content) -> some View {
>         content
>             .navigationTitle("")
>             .navigationBarTitleDisplayMode(.inline)
>             .navigationBarBackButtonHidden(true)
>             // Asked for by name: SwiftUI drops a bar that has nothing in it.
>             .toolbar(.visible, for: .navigationBar)
>             .toolbarBackground(.hidden, for: .navigationBar)
>             .background(NavigationBarInset().accessibilityHidden(true))
>     }
> }
>
> /// Takes the bar's height 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.
> struct NavigationBarInset: UIViewControllerRepresentable {
>     func makeUIViewController(context: Context) -> NavigationBarInsetController { NavigationBarInsetController() }
>     func updateUIViewController(_ controller: NavigationBarInsetController, context: Context) {}
> }
>
> final class NavigationBarInsetController: UIViewController {
>     override func loadView() {
>         let view = UIView(frame: .zero)
>         view.isUserInteractionEnabled = false
>         view.isHidden = true
>         self.view = view
>     }
>
>     override func didMove(toParent parent: UIViewController?) {
>         super.didMove(toParent: parent)
>         apply()
>     }
>
>     override func viewWillAppear(_ animated: Bool) {
>         super.viewWillAppear(animated)
>         apply()
>     }
>
>     override func viewDidLayoutSubviews() {
>         super.viewDidLayoutSubviews()
>         apply()
>     }
>
>     private func apply() {
>         guard let navigation = navigationController else { return }
>         // The screen: the controller the stack shows, whose safe area the bar adds to.
>         var screen: UIViewController = self
>         while let parent = screen.parent, parent !== navigation { screen = parent }
>         let barHeight = navigation.isNavigationBarHidden ? 0 : navigation.navigationBar.frame.height
>         if screen.additionalSafeAreaInsets.top != -barHeight { screen.additionalSafeAreaInsets.top = -barHeight }
>     }
> }
>
> /// 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 }
>         }
>     }
> }
> ```

> [tab] UIKit
>
> Create `MessageViewController.swift`. `CometChatMessageHeader`, `CometChatMessageList` and
> `CometChatMessageComposer` are `UIView`s: give each the chat. 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 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 MessageViewController.swift theme={null}
> import UIKit
> import CometChatUIKit
> import CometChatSDK
>
> final class MessageViewController: UIViewController {
>     private let user: CometChatSDK.User?
>     private let group: CometChatSDK.Group?
>     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 }
>
>     init(user: CometChatSDK.User?, group: CometChatSDK.Group?) {
>         self.user = user
>         self.group = group
>         super.init(nibName: nil, bundle: nil)
>         hidesBottomBarWhenPushed = true
>     }
>
>     required init?(coder: NSCoder) { fatalError("init(coder:) is not supported") }
>
>     override func viewDidLoad() {
>         super.viewDidLoad()
>         view.backgroundColor = .systemBackground
>         clearNavigationBar()
>
>         if let user {
>             header.set(user: user)
>             messageList.set(user: user)
>             composer.set(user: user)
>         } else if let group {
>             header.set(group: group)
>             messageList.set(group: group)
>             composer.set(group: group)
>         }
>         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),
>         ])
>     }
> }
> ```

![A chat: messages with reactions, a quoted reply with a thread, a missed call, the New separator, an edited and a deleted message](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-messageListMixed.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=d1afd10cac22a4e9d085b7e6ff226d42)

***

## Step 3: Show It After Login

> [tab] SwiftUI
>
> Render `ChatsView` from `ContentView` once `login` finishes:
>
> ```swift ContentView.swift theme={null}
> import SwiftUI
> import CometChatSwiftUI
>
> struct ContentView: View {
>     @State private var isReady = false
>     @State private var errorText: String?
>
>     var body: some View {
>         Group {
>             if let errorText {
>                 Text(errorText)
>             } else if isReady {
>                 ChatsView()
>             } else {
>                 ProgressView()
>             }
>         }
>         .task {
>             do {
>                 try await CometChatSession.initialize(appID: "APP_ID", region: "REGION")
>                 if CometChatSession.loggedInUser == nil {
>                     _ = try await CometChatSession.login(uid: "UID", authKey: "AUTH_KEY")
>                 }
>                 isReady = true
>             } catch {
>                 errorText = error.localizedDescription
>             }
>         }
>     }
> }
> ```

> [tab] UIKit
>
> Make a navigation controller holding `ChatsViewController` the window's root once `login` finishes:
>
> ```swift SceneDelegate.swift theme={null}
> import UIKit
> import CometChatUIKit
>
> final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
>     var window: UIWindow?
>
>     func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
>                options connectionOptions: UIScene.ConnectionOptions) {
>         guard let windowScene = scene as? UIWindowScene else { return }
>         let window = UIWindow(windowScene: windowScene)
>         window.rootViewController = UIViewController()
>         window.makeKeyAndVisible()
>         self.window = window
>
>         Task {
>             do {
>                 try await CometChatSession.initialize(appID: "APP_ID", region: "REGION")
>                 if CometChatSession.loggedInUser == nil {
>                     _ = try await CometChatSession.login(uid: "UID", authKey: "AUTH_KEY")
>                 }
>                 window.rootViewController = UINavigationController(rootViewController: ChatsViewController())
>             } catch {
>                 print("CometChat could not start:", error)
>             }
>         }
>     }
> }
> ```

***

## Step 4: Run the Project

Build and run. The logged-in user's conversations load; tap one to open the chat, and the header's back
button returns to the list. Messages you send appear at once, and incoming ones arrive live.

The composer needs the camera, microphone and photo-library usage descriptions in `Info.plist` — see
Step 3 of [Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started.md).

***

## Next Steps

> [card] [Components Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/components-overview.md)
>
> Explore all available UI Kit components and their customization options

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> Customize colors, fonts, and styles to match your brand

> [card] [Integration](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started.md)
>
> Back to the main integration guide

> [card] [Feature Guides](https://www.cometchat.com/docs/ui-kit/ios/v6/guide-overview.md)
>
> Add capabilities like threaded messages, blocking, and group management


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