SDKsAndroidEnterprise
Pin or unpin a message
Change a conversation message’s pinned state and handle pinned-message change events.
Pin an important message to the top of a conversation or unpin a previously pinned message. Pinned status is a shared conversation attribute. In group chats, pinning is typically restricted to group owners and administrators. Once pinned, member devices display the message prominently in a pinned banner at the top of the chat screen.
Code example
String conversationID = "g_group_123";
String clientMsgID = "msg_001";
boolean isPinned = true; // true: pin the message; false: unpin the message
OpenIMClient.getInstance().messageManager.setConversationPinnedMsg(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Pinned status updated successfully
}
@Override
public void onError(int code, String error) {
// Handle update failure
}
},
conversationID,
clientMsgID,
isPinned
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
conversationID | String | Yes | Globally unique ID of the target conversation. |
clientMsgID | String | Yes | Client message ID of the target message to pin or unpin. |
isPinned | boolean | Yes | Pin status flag: true to pin the message, false to unpin it. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the pinned state change was saved on the server. - Asynchronous event delivery: Conversation members receive the change event through
OnAdvanceMsgListener.onChangedPinnedMsg:
@Override
public void onChangedPinnedMsg(ChangedPinnedMsg event) {
// event.getConversationID() identifies the target conversation
// event.getMsgs() returns the updated list of pinned messages
}Clients should merge the new list of pinned items using event.getConversationID() and clientMsgID.
- Re-query calibration: To retrieve the complete current list of pinned messages directly from storage, see View pinned messages.
For complete listener registration and lifecycle management, see Receive messages.
Was this page helpful?