Skip to main content
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.

Where It Fits

Pinned messages are scoped to one conversation, so this screen is opened from that conversation — typically the overflow menu in CometChatMessageHeader. 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.
This screen is read-only by design: opening it never marks anything as read, sends receipts, or changes the unread count.

Minimal Render

CometChatPinnedMessages is a view controller, so push it onto your navigation stack.
Pass either user or group — they are mutually exclusive and scope the list to that conversation.

Filtering

The list is fetched with a MessagesRequest.MessageRequestBuilder. The default comes from PinnedMessagesBuilder:
The server caps pins at 100 per conversation, so a limit of 100 fetches the entire list in one page. To narrow the list further, supply your own builder:
A custom request builder must keep set(pinned: true). Without it the request returns every message in the conversation and the screen lists them all as though they were pinned.

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 from CometChatListBase. 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 on CometChatMessageEvents. See Events.

Custom View Slots

Each row is a CometChatMessageBubble 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:
Rows group under a date divider per day, ordered newest pin first. Hide the dividers with 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 with user; 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 with group; pass it to the initializer.

Methods

set(requestBuilder:)

Replaces the request used to fetch the list. Must retain set(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


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