Skip to main content
Let users keep their most important chats at the top of the list. Pinning a conversation is per-user — it changes the order of the acting user’s own conversation list and is synced across their devices. A conversation can also be pinned globally for everyone by the app itself (a system pin). Let’s see how to work with pinned conversations in CometChat’s Android SDK.
Pinning a conversation with the SDK requires the Pin Conversation feature to be enabled for your app. You can check its availability at runtime using the feature flag.

Pin a Conversation

To pin a conversation, use the pinConversation method. Pass the UID of the other user (for a one-on-one conversation) or the GUID of the group, along with the matching conversation type. On success, the callback returns the updated Conversation with its pin attributes set.

Unpin a Conversation

To unpin a conversation, use the unpinConversation method with the same parameters. On success, the callback returns the updated Conversation with its pin attributes cleared.
A user cannot unpin a system pin (a conversation pinned globally by the app). Use isSystemPinned() to detect this case and hide the unpin action.

Fetch Pinned Conversations

The default conversations list already orders pinned conversations at the top. To fetch only pinned conversations, use the setPinnedBy() filter of the ConversationsRequestBuilder.

Check if a Conversation is Pinned

Every fetched Conversation carries its pin state.

Real-time Conversation Pin Events

Register a ConversationListener to be notified when a conversation is pinned or unpinned, so your list can reorder without a refetch. Today these callbacks fire on the acting user’s device when a pin or unpin succeeds. Delivery to the user’s other devices activates once server-side real-time delivery for conversation-pin events is rolled out — until then, other sessions pick up the change on their next conversations fetch.
To stop listening, remove the listener with CometChat.removeConversationListener(listenerID).

Pin Limit

A user can pin a capped number of conversations, configurable per app. Read the cap rather than hard-coding it — it is tenant-overridable and will drift.
Both are synchronous and never throw. They return Settings.LIMIT_UNSPECIFIED (-1) when the app settings carry no value or when they are called before init() completes — show generic copy in that case rather than guessing a number. getSystemPinConversationLimit() is the separate cap for admin/global pins: system pins do not consume a user’s allowance, so the two budgets are enforced independently. When the limit is breached, the SDK surfaces the server error through onError, and the applicable limit is carried in the exception’s errorParams:

Error Handling

Feature Availability

Check whether the Pin Conversation 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.

Next Steps

Pin A Message

Highlight a message for everyone in the conversation

Save A Message

Bookmark a message privately, across conversations

Retrieve Conversations

Every filter the conversations list supports

All Real Time Listeners

Every listener the SDK exposes, in one place