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).

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.