Skip to main content
This guide builds a single chat window — no sidebar, no conversation list. Users go directly into a one-to-one or group chat. Good for support chat, contextual messaging, or any focused messaging experience. This assumes you’ve already completed iOS Integration (project created, UI Kit installed, init + login working, permissions configured).

What You’re Building

Three components stacked vertically:
  1. Chat header — displays recipient name, avatar, online status, and optional call buttons
  2. Message list — real-time chat history with scrolling
  3. Message composer — text input with media, emojis, and reactions

Step 1 — Setup SceneDelegate

Fetch the user (or group) after login and launch directly into the messages view.
SceneDelegate.swift
Key points:
  • CometChat.getUser(UID:) fetches the user object from the SDK — you need a real user object, not a manually constructed one.
  • The highlighted lines show where to set the credentials and the UID of the user to chat with.

Switching Between User and Group Chat

To load a group chat instead of one-to-one, replace getUser with getGroup:

Step 2 — Create MessagesVC

Create a new Swift file for the messages view controller:
  1. In Xcode, right-click your project folder in the Navigator
  2. Select New File…
  3. Choose Swift File and click Next
  4. Name it MessagesVC.swift and click Create
Add the following code. This view controller assembles the header, message list, and composer.
MessagesVC.swift
How it works:
  • CometChatMessageHeader shows user/group info and back button
  • CometChatMessageList displays messages with real-time updates
  • CometChatMessageComposer handles text input, media, and reactions
  • Pass either user or group to each component, never both

Step 3 — Run the Project

Build and run in Xcode. You should see the chat window load directly with the conversation for the UID you set.

Next Steps

Theming

Customize colors, fonts, and styles to match your brand

Components Overview

Browse all prebuilt UI components

iOS Integration

Back to the main setup guide

Core Features

Chat features included out of the box