Skip to main content
Keep important messages easy to find by pinning them to a conversation. A pinned message is visible to all participants of the conversation, along with who pinned it and when. Users can pin messages, unpin them, and fetch all pinned messages of a conversation. You can also listen to pin events in real-time. Let’s see how to work with pinned messages in CometChat’s Android SDK.
Pinning a message with the SDK requires the Pin Message feature to be enabled for your app. You can check its availability at runtime using the feature flag.

Pin a Message

To pin a message, use the pinMessage method and pass the ID of the message to be pinned. On success, the callback returns the updated BaseMessage with its pin attributes set.
In a group conversation, the CometChat UI Kits show the Pin/Unpin option only to participants with the Admin or Moderator scope, or the group owner. This gate is applied client-side — the SDK does not currently enforce roles on the server, so apply your own role check if you build custom pin UI. Every participant can see pinned messages. In a one-on-one conversation, both participants can pin and unpin. Deleted messages cannot be pinned; deleting a pinned message automatically unpins it.

Unpin a Message

To unpin a message, use the unpinMessage method. Any participant with pin permission can unpin a message — not just the user who originally pinned it. On success, the callback returns the updated BaseMessage with its pin attributes cleared.

Fetch Pinned Messages

To fetch all pinned messages of a conversation, create a MessagesRequest with the setPinned(true) filter of the MessagesRequestBuilder. Setting a UID (for a one-on-one conversation) or a GUID (for a group) is mandatory — exactly one of the two. The returned list is sorted by the time of pinning, most recently pinned first.

Check if a Message is Pinned

Every fetched or received message carries its pin state on the BaseMessage itself.
Editing a message preserves its pin. A message stores only its most recent pinner in getPinnedBy().

Real-time Pin Events

Register a MessageListener and override the pin callbacks. Each event delivers the full updated BaseMessage, so you can directly replace the message in your list. Today these callbacks fire on the acting user’s device when a pin or unpin succeeds. Delivery to other participants activates once server-side real-time delivery for pin events is rolled out — until then, other clients pick up pin changes on their next message fetch.
To stop listening, remove the listener with CometChat.removeMessageListener(listenerID).

Pin Limit

A conversation can hold a limited number of pinned messages (100 by default). When the limit is exceeded, the SDK surfaces the server error through onError, and the applicable limit can be read programmatically from the exception — never hard-code it.

Feature Availability

Check whether the Pin Message feature is enabled for your app before showing pin actions in your UI. The method is synchronous and safe to call from the UI layer.