Skip to main content
Available from Chat SDK v5.0.7. These APIs require cometchat_sdk v5.0.7 or later. See Setup to upgrade.
Pinning a conversation keeps it at the top of the logged-in user’s conversation list. The pin is private to that user — nobody else sees it — and it syncs to their other devices. A pinned conversation carries a pinnedAt timestamp and the pinnedBy UID.
This is separate from an admin (system) pin, which is applied from an admin surface such as the CometChat Dashboard and carries the app_system sentinel in pinnedBy. System pins rank above the user’s own pins and cannot be created or removed from the SDK, only observed.

Pin a Conversation

A conversation is addressed by its peer — the other user’s UID for a one-on-one conversation, or the GUID for a group — together with the conversation type.
On success, onSuccess receives the full updated Conversation, with pinnedAt and pinnedBy set. Pinning is idempotent.
Addressing by peer rather than by conversationId is deliberate: it lets you pin a conversation that has no messages yet.

Unpin a Conversation

The returned Conversation carries its pin fields cleared to null. Only a pin the logged-in user placed can be removed — a system pin is rejected server-side, so hide or disable the unpin control for conversations whose pinnedBy is app_system.

Fetch Pinned Conversations

The default conversation list is already pin-ordered by the server: system pins first, then the user’s own pins, then everything else by latest activity. Fetch it with the regular ConversationsRequest described in Retrieve Conversations — no extra filter is needed.
When you apply real-time events to a list you already hold, keep the same ordering contract: system pins stay above user pins, and user pins stay above the activity-ordered rest of the list — new activity moves a conversation to the top of its own section only.

Check if a Conversation is Pinned

As with messages, a null pinnedAt means the conversation is not pinned.

Real-time Conversation Pin Events

Conversation pins arrive on a dedicated ConversationListener, not on MessageListener — the payload is a Conversation, not a message. Register it with addConversationListener() and override onConversationPinned() and onConversationUnpinned().
These fire for the logged-in user’s own pins — on the acting device as soon as the call succeeds, and over the socket on their other devices — and when a system pin is applied server-side. They never fire because another user pinned their own list. Remove the listener when you are done:
Adding a listener with an ID that is already registered silently replaces the earlier one. Use a unique ID per registration site.

Pin Limit

getPinnedConversationsLimit() is synchronous and returns null when the backend did not serve a limit. System pins do not count against the user’s allowance.

Error Handling

pinConversation() and unpinConversation() report failures through onError with a CometChatException. Branch on e.code rather than the message text: Pins are per-user, so pinning a conversation never affects anyone else’s list. Both calls are idempotent: unpinning a conversation that was never pinned succeeds rather than erroring.

Feature Availability

isPinConversationEnabled() is synchronous and never throws. When neither the login payload nor the app settings carry the flag, it returns true, so the feature is not disabled on a backend that predates the flag.

Next Steps

Retrieve Conversations

Fetch and order the conversation list

Pin A Message

Highlight a message for everyone in a conversation

Save A Message

Bookmark a message privately, across conversations

All Real Time Listeners

Every listener the SDK exposes, in one place