CometChatPinnedMessages is a full-screen list of the messages pinned in a single conversation, newest pin first. Pins are conversation-wide: everyone in the chat sees the same list, and moderators can unpin from any row.
AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
Pinned messages are scoped to one conversation, so this screen is opened from that conversation — typically the overflow menu inCometChatMessageHeader. Tapping a row takes the user back to the chat and scrolls to the message.
Contrast with Saved Messages, which is a user-level screen spanning every conversation and is reached from your app’s chrome instead.
Pin and save are off by default. Set
enablePinMessage on your CometChatMessageList and enable the feature for your app, or no pin options appear and this screen stays empty. See the Pin and Save Messages guide.Minimal Render
CometChatPinnedMessages is a view controller, so push it onto your navigation stack.
user or group — they are mutually exclusive and scope the list to that conversation.
Filtering
The list is fetched with aMessagesRequest.MessageRequestBuilder. The default comes from PinnedMessagesBuilder:
Actions and Events
Callback Props
onMessageClicked
Fires when a row is tapped. Use it to return to the conversation and jump to the message.onError
Fires when the fetch fails, and again when an unpin fails.onLoad
Fires with the fetched messages each time the list reloads.onEmpty
Fires when the fetch completes with no pinned messages.onBack
Inherited fromCometChatListBase. The component ships a default that pops the navigation stack; set your own to replace it.
Actions Reference
Global UI Events
Pin and unpin actions performed elsewhere in the kit emit onCometChatMessageEvents. See Events.
Custom View Slots
Each row is aCometChatMessageBubble built from the same message templates the message
list uses, so pinned photos, videos and files render as real bubbles. Rows are left-aligned
regardless of sender — including your own, which keep their outgoing bubble color but sit on
the left with an avatar and name. Each slot below receives the row’s BaseMessage and
returns a view that replaces one part of that bubble.
set(titleView:)
Replaces the bubble’s header, which carries the sender name by default.set(subtitle:)
Replaces the bubble’s content — the rendered message body.set(trailingView:)
Replaces the bubble’s status-info slot, which holds the timestamp and read receipt.set(listItemView:)
Replaces the entire bubble. Use this when the slots above are not enough.Message templates
To change how one message type renders, override its template rather than a slot. This keeps every other type on its default bubble.Styling
Style Hierarchy
PinnedMessagesStyle conforms to ListBaseStyle, so it carries the standard screen-level properties plus the pin-specific ones. Bubble appearance is separate — set it through messageBubbleStyle.
Global Level Styling
Applies to every instance created afterwards.Instance Level Styling
Key Style Properties
Bubbles are styled through
messageBubbleStyle, the date dividers through dateSeparatorStyle, and avatars through avatarStyle:
set(hideDateSeparator: true).
Customization Matrix
Props
All props are optional. Sorted alphabetically.avatarStyle
Styling for the sender avatar beside incoming bubbles.dateSeparatorStyle
Styling for the per-day date divider above each group of rows.messageBubbleStyle
Appearance of the incoming and outgoing bubbles.messageAlignment
Every pinned message is left-aligned by default, the logged-in user’s included, so each row is attributed by its avatar and sender name rather than by position. Set.standard to
mirror the message list and align your own messages right.
hideDateSeparator
Hides the per-day date dividers.dateTimeFormatter
Custom timestamp formatting.group
The group whose pinned messages to show. Mutually exclusive withuser; pass it to the initializer.
hideUnpinOption
Hides the per-row unpin swipe action. Set this for users who cannot pin in this conversation.style
The component’s style object.user
The user whose pinned messages to show. Mutually exclusive withgroup; pass it to the initializer.
Methods
set(requestBuilder:)
Replaces the request used to fetch the list. Must retainset(pinned: true).
set(textFormatters:)
Applies custom text formatters to the message previews, matching the formatters used in your message list.PinnedMessagesViewModel is public in name only — every member except setRequestBuilder(requestBuilder:) is internal. Customize through the props and view slots above rather than the view model.Common Patterns
Open from the message header and jump to the message
The complete round trip: open the panel from the conversation, then return and scroll to the tapped message.Hide unpin for users without permission
Pinning is restricted to group owners, admins and moderators. Hide the unpin action for everyone else so the swipe does not fail against the server.Custom empty state
Related Components
- Saved Messages - The user-level saved messages screen
- Message List - Where messages are pinned and unpinned
- Message Header - Hosts the menu that opens this screen
- Events - Pin and save event callbacks
Pin and Save Messages Guide
End-to-end setup for pinning and saving
Chat SDK: Pin and Save
The underlying SDK methods and message fields