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 thepinConversation 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.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Unpin a Conversation
To unpin a conversation, use theunpinConversation method with the same parameters. On success, the callback returns the updated Conversation with its pin attributes cleared.
- Java
- Kotlin
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 thesetPinnedBy() filter of the ConversationsRequestBuilder.
- Java
- Kotlin
Check if a Conversation is Pinned
Every fetchedConversation carries its pin state.
Real-time Conversation Pin Events
Register aConversationListener 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.
- Java
- Kotlin
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.- Java
- Kotlin