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

Where It Fits
- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
CometChatMessageHeader(group: group).
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.
- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
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:- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
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:AI agents
- SwiftUI
- UIKit
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:- SwiftUI
- UIKit
Each slot is 
Or as modifiers, for every header in a subtree — an initialiser argument wins:The modifiers are
(ChatUser?, ChatGroup?) -> AnyView (MessageHeaderSlot).
cometChatMessageHeaderLeadingView, …TitleView, …SubtitleView,
…TrailingView, …AuxiliaryView and …ItemView.Menu Options
- SwiftUI
- UIKit
The ⋯ appears only when
hideMenuIcon is false and there are options — both. It opens
a native menu on one tap.Pinned Messages
- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
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.CometChatCallButtons.
Advanced Methods
Store Access
- SwiftUI
- UIKit
Pass a
MessageHeaderStore to seed the header or share it, and to refresh the subject
yourself:Subclassing
- SwiftUI
- UIKit
CometChatMessageHeader is a View struct. Customise it with its slots, modifiers and
style.Style
- SwiftUI
- UIKit
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



