> ## 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 Tab-Based Messaging UI

> Create a tab-based messaging UI with Chats, Calls, Users and Groups tabs, using the CometChat iOS UI Kit v6 SwiftUI or UIKit toolkit.

> [accordion] AI Integration Quick Reference
>
> | Field | Value |
> | - | - |
> | Components | `CometChatConversations`, `CometChatCallLogs`, `CometChatUsers`, `CometChatGroups` |
> | Layout | Tab bar (Chats, Calls, Users, Groups), a navigation stack per tab |
> | SwiftUI | `TabView` with a `NavigationStack` per tab; lists take `embedsNavigationStack: false` |
> | UIKit | `UITabBarController` with a `UINavigationController` per tab; lists are view controllers |
> | Calling | The Calls tab needs `CometChatSession.initialize(appID:region:enableCalling: true)` |
> | 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, and the chat screen from [Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md) |
> | Pattern | Full-featured messaging app with multiple sections |

This guide builds a tabbed messaging UI — Chats, Calls, Users and Groups in a tab bar, each tab showing
its CometChat component, and a tap on a conversation, user or group opening the chat.

It assumes you have completed the Getting Started guide for your toolkit (project created, package added,
`initialize` and `login` working), and reuses the chat screen and conversation list from
[Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md) — `MessageView` and
`ChatsView` in SwiftUI, `MessageViewController` and `ChatsViewController` in UIKit.

***

## What You're Building

Two parts working together:

1. **Tab bar** — switches between Chats, Calls, Users and Groups
2. **Content area** — the CometChat component for the selected tab, in its own navigation stack, which
   the chat is pushed onto

> [tab] SwiftUI
>
> A `TabView` with one `Tab` per section. Each tab has its own `NavigationStack`, so a chat pushed from
> Users stays in the Users tab.

> [tab] UIKit
>
> A `UITabBarController` whose view controllers are `UINavigationController`s, each holding a CometChat
> list view controller.

***

## Step 1: Set Up the Tabbed Screen

> [tab] SwiftUI
>
> Create `HomeView.swift`. The Chats tab is `ChatsView`, which already has its stack; the others wrap their
> list in a `NavigationStack` and pass `embedsNavigationStack: false`, so the list uses yours:
>
> ```swift HomeView.swift theme={null}
> import SwiftUI
> import CometChatSwiftUI
>
> struct HomeView: View {
>     var body: some View {
>         TabView {
>             Tab("Chats", systemImage: "bubble.left.and.bubble.right") {
>                 ChatsView()
>             }
>             Tab("Calls", systemImage: "phone") {
>                 NavigationStack {
>                     CometChatCallLogs(embedsNavigationStack: false)
>                 }
>             }
>             Tab("Users", systemImage: "person") {
>                 UsersView()
>             }
>             Tab("Groups", systemImage: "person.2") {
>                 GroupsView()
>             }
>         }
>     }
> }
> ```

> [tab] UIKit
>
> Create `HomeTabBarController.swift`. Each tab is a navigation controller holding a CometChat list, and the
> Users and Groups lists push the chat on a tap:
>
> ```swift HomeTabBarController.swift theme={null}
> import UIKit
> import CometChatUIKit
>
> final class HomeTabBarController: UITabBarController {
>     override func viewDidLoad() {
>         super.viewDidLoad()
>
>         let chats = ChatsViewController()
>         chats.tabBarItem = UITabBarItem(title: "Chats",
>                                         image: UIImage(systemName: "bubble.left.and.bubble.right"), tag: 0)
>
>         let calls = CometChatCallLogs()
>         calls.tabBarItem = UITabBarItem(title: "Calls", image: UIImage(systemName: "phone"), tag: 1)
>
>         let users = CometChatUsers()
>         users.set(onItemClick: { [weak users] user, _ in
>             let chat = MessageViewController(user: user, group: nil)
>             users?.navigationController?.pushViewController(chat, animated: true)
>         })
>         users.tabBarItem = UITabBarItem(title: "Users", image: UIImage(systemName: "person"), tag: 2)
>
>         let groups = CometChatGroups()
>         groups.set(onItemClick: { [weak groups] group, _ in
>             let chat = MessageViewController(user: nil, group: group)
>             groups?.navigationController?.pushViewController(chat, animated: true)
>         })
>         groups.tabBarItem = UITabBarItem(title: "Groups", image: UIImage(systemName: "person.2"), tag: 3)
>
>         viewControllers = [chats, calls, users, groups].map {
>             UINavigationController(rootViewController: $0)
>         }
>     }
> }
> ```
>
> `MessageViewController` sets `hidesBottomBarWhenPushed`, so the tab bar slides away while a chat is open.

***

## Step 2: Create Tab Content

> [tab] SwiftUI
>
> Add the Users and Groups tabs. Each holds the tapped user or group in `@State` and pushes the chat with
> `navigationDestination(item:)` — `MessageView` hides the tab bar while it is on screen:
>
> ```swift UsersView.swift theme={null}
> import SwiftUI
> import CometChatSwiftUI
> import CometChatSDK
>
> struct UsersView: View {
>     @State private var chatUser: CometChatSDK.User?
>
>     var body: some View {
>         NavigationStack {
>             CometChatUsers(embedsNavigationStack: false, onItemClick: { user in chatUser = user })
>                 .navigationDestination(item: $chatUser) { user in
>                     MessageView(user: user, group: nil)
>                 }
>         }
>     }
> }
>
> struct GroupsView: View {
>     @State private var chatGroup: CometChatSDK.Group?
>
>     var body: some View {
>         NavigationStack {
>             CometChatGroups(embedsNavigationStack: false, onItemClick: { group in chatGroup = group })
>                 .navigationDestination(item: $chatGroup) { group in
>                     MessageView(user: nil, group: group)
>                 }
>         }
>     }
> }
> ```

> [tab] UIKit
>
> No separate files needed — the tab content is created in `HomeTabBarController` above. `ChatsViewController`
> and `MessageViewController` come from
> [Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md).

> [!NOTE]
>
> The Calls tab lists call history and starts calls, which needs calling turned on at initialisation:
> `CometChatSession.initialize(appID:region:enableCalling: true)`. Without it, leave the Calls tab out. See
> [Calling Integration](https://www.cometchat.com/docs/ui-kit/ios/v6/calling-integration.md).

***

## Step 3: Launch the Tabbed Screen

> [tab] SwiftUI
>
> Render `HomeView` 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 {
>                 HomeView()
>             } else {
>                 ProgressView()
>             }
>         }
>         .task {
>             do {
>                 try await CometChatSession.initialize(appID: "APP_ID", region: "REGION", enableCalling: true)
>                 if CometChatSession.loggedInUser == nil {
>                     _ = try await CometChatSession.login(uid: "UID", authKey: "AUTH_KEY")
>                 }
>                 isReady = true
>             } catch {
>                 errorText = error.localizedDescription
>             }
>         }
>     }
> }
> ```

> [tab] UIKit
>
> Make `HomeTabBarController` 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", enableCalling: true)
>                 if CometChatSession.loggedInUser == nil {
>                     _ = try await CometChatSession.login(uid: "UID", authKey: "AUTH_KEY")
>                 }
>                 window.rootViewController = HomeTabBarController()
>             } catch {
>                 print("CometChat could not start:", error)
>             }
>         }
>     }
> }
> ```

***

## Step 4: Run the Project

Build and run. The tab bar shows Chats, Calls, Users and Groups; a tap on a conversation, user or group
opens the chat in that tab. On iOS 26 the tab bar and the lists' navigation bars are Liquid Glass. 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.