Skip to main content
CometChatMessageHeader is the bar at the top of a conversation. It shows who you are talking to — a user or a group — with their avatar, and a subtitle that stays live: online, last seen, typing, or a group’s member count. It looks like a standard iOS app’s header. There’s no full-width strip: three separate elements float over the message list, and the list scrolls under them.
  • Back circle: a 44pt circle holding the back chevron.
  • Identity pill: a capsule that takes the remaining width, with the avatar (and a group’s badge), the name, and the subtitle.
  • Trailing pill: the call buttons, then new chat and chat history, then the ⋯ menu, then your trailing view. Each button is 44pt wide; a pill with one button is a 44pt circle. With nothing to show, the pill isn’t drawn and the identity pill takes the space.
On iOS 26 each element is Liquid Glass. On iOS 18–25, and with Reduce Transparency on, the same elements are filled with the theme’s background1 and outlined with a one-pixel strokeLight edge. The whole layout mirrors in a right-to-left language, and the identity pill grows with Dynamic Type instead of clipping.
CometChatMessageHeader showing a user's avatar, name and online status with a back button

Where It Fits

Give it the chat’s User or Group. It fetches nothing to start, so it renders at once, then keeps itself current from the SDK and the Kit’s event bus.

Quick Start

In a chat, host the header as a bar over the message list, as Conversation List + Message View shows.A group works the same way — CometChatMessageHeader(group: group).
A group header: the back circle, the identity pill with the avatar and its private-group badge, Team Leads over 12 Members, and the new-chat button in the trailing pill
Back calls onBack and nothing else. The header never dismisses or pops by itself — your navigation decides what “back” means.

What the Subtitle Says

One line, decided in this order: The typing line clears one second after the typist stops.
With the name hidden by a blocked user or hideUserStatus, the name centres. The last-seen text reads “Last seen 17 minutes ago”, “Last seen 2 hours ago”, “Last seen 3 days ago” or “Last seen Just now”.

Your own “Last seen” text

lastSeenTextFormatter replaces the whole line for an offline user:
dateTimeFormatter is the Kit-wide nine-bucket formatter. The SwiftUI header asks it for otherDays only, and puts “Last seen” in front of its answer.

Actions and Events

Callback Methods

Global Events

Your own actions arrive through the Kit’s event bus — the SDK does not tell you about what you did yourself. The header listens for:
If you build your own group screens and do not emit these events, the header’s member count goes stale until the next reconnect. Emit them where the action succeeds.
See Events for the whole bus.

SDK Events (Real-Time, Automatic)

The header stays current on its own:
  • presence and last-active time, from the SDK — not while either side has blocked the other;
  • typing, from the SDK;
  • a group’s member count when members join, leave, are added, kicked or banned by someone else, from the SDK;
  • after a reconnect, the subject is fetched again.

Functionality

The data and formatting parameters are user, group, store (MessageHeaderStore?), lastSeenTextFormatter ((ChatUser) -> String), dateTimeFormatter, imageSource (any ImageSource, default CometChatSharedImageSource()) and style (CometChatMessageHeaderStyle).The same parts can be hidden for a whole subtree:
A subtree can hide more than a header’s own flags, never less.

AI agents

When the user is an AI agent (role == "@agentic"), the header shows the new-chat and chat-history buttons and “AI Assistant”, and hides the call buttons and presence — whatever the flags say. For the next person, the flags apply again. Handle the two buttons:

Custom View Slots

Each region can be replaced. The slot receives the chat’s user or group — whichever the chat is:
Each slot is (ChatUser?, ChatGroup?) -> AnyView (MessageHeaderSlot).
The header with a custom subtitle view in place of the member count
Or as modifiers, for every header in a subtree — an initialiser argument wins:
The modifiers are cometChatMessageHeaderLeadingView, …TitleView, …SubtitleView, …TrailingView, …AuxiliaryView and …ItemView.

The ⋯ appears only when hideMenuIcon is false and there are options — both. It opens a native menu on one tap.

Pinned Messages

showPinnedMessagesOption adds a Pinned messages entry, first in the menu, and shows the ⋯ without hideMenuIcon: false. The entry appears only when pinning is enabled for your app (CometChatSession.isPinMessageEnabled()); with pinning off and no options of yours, there is no ⋯. A tap calls onPinnedMessagesClick — open Pinned Messages from there:

Calls

The voice and video buttons are hidden by default. Turning them on shows them only when the Calls SDK is linked, calling is enabled, and something can show the call — your app, through onVoiceCallClick / onVideoCallClick:
Calling is enabled with CometChatSession.initialize(appID:region:enableCalling: true), and is off by default. The Kit’s own call screens are not released yet. Until they are, the call buttons render only for an app that handles the tap itself — a button that started a call nobody could see would ring the other person while you saw nothing.
The buttons are CometChatCallButtons.

Advanced Methods

Store Access

Pass a MessageHeaderStore to seed the header or share it, and to refresh the subject yourself:

Subclassing

CometChatMessageHeader is a View struct. Customise it with its slots, modifiers and style.

Style

CometChatMessageHeaderStyle is sparse: set only what you change, and everything else follows the theme.
popupMenuStyle exists but isn’t applied: the ⋯ opens the system menu.

Next Steps

Message List

The messages shown below the header

Call Buttons

The voice and video buttons the header hosts

Pinned Messages

Open from the header’s menu

Events

The Kit’s event bus