AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
CometChatPinnedMessages is a full-screen component that lists every message pinned in a single conversation, most recently pinned first. Each row renders the actual message bubble — with the sender’s avatar, name and date — so pinned media, files and text all look exactly as they do in the chat. Open it from your conversation screen (the Message Header provides a built-in “Pinned messages” menu item for this), and wire setOnMessageClickListener to navigate back to the message in context.
Messages are pinned and unpinned from the Message List action sheet; this screen is the read view, plus a long-press menu on each row (Message info, Copy, Unpin, Subscribe/Unsubscribe to thread, Delete).
Pinned messages require the Pin Message feature to be enabled for your app. Gate your entry point with
CometChatUIKit.isPinMessageEnabled().Quick Start
- Kotlin (XML Views)
- Jetpack Compose
Add the component to your layout XML:Scope it to the conversation and wire the callbacks:
activity_pinned_messages.xml
PinnedMessagesActivity.kt
Actions and Events
Callback Methods
SDK Events (Real-Time, Automatic)
The list keeps itself up to date — when the logged-in user pins or unpins a message anywhere in the app, the row is added or removed without a refetch, via theMessagePinned / MessageUnpinned events on the UI Kit event bus; see Events. Pins made by other participants appear when the list is next opened or refetched (server-side real-time delivery for pin events is pending rollout).
Functionality
- Real bubbles — each row hosts the message’s actual bubble (text, image, video, audio, file), left-aligned with a
name • dateheader and the sender’s avatar. Your own messages render with the outgoing (primary-color) bubble style and the name You. - Long-press menu — long-press a row for message actions: Message info, Copy, Unpin, Subscribe/Unsubscribe to thread, and Delete. Unpinning asks for confirmation before it is performed.
- Jump to message — tapping a row emits the message through the click callback so you can open the conversation and scroll to it.
- Empty state — a built-in empty state (“No pinned messages yet”) is shown when the conversation has no pinned messages.
- Read-only — the screen never marks messages as read and does not affect unread counts or receipts.
ViewModel
The screen is backed byCometChatPinnedMessagesViewModel (in the shared core module), which fetches via MessagesRequestBuilder().setPinned(true) scoped to the set user or group, applies optimistic unpin with revert-on-error, and observes the event bus for live upkeep. In Compose you can inject your own instance through the viewModel parameter.
Next Steps
- Message List — where messages are pinned and unpinned, and where the bubble pin indicator appears.
- Message Header — the built-in “Pinned messages” menu entry point.
- Saved Messages — the private, cross-conversation counterpart.
- Pin A Message (SDK) — the underlying SDK APIs.