SDKsWASMEnterprise
Pin or unpin a message
Pin or unpin one message with the WASM SDK.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | ID of the conversation containing the message. |
clientMsgID | string | Yes | ID of the message to pin or unpin. |
pinned | boolean | Yes | true to pin the message; false to unpin it. |
await openimsdk.setConversationPinnedMsg({
conversationID,
clientMsgID: message.clientMsgID,
pinned: true,
});OpenIMServer validates permissions, message types, and quantity limits. Promise completion means that the pinning request has completed; it does not mean the change event has already arrived.
Listen for SdkEvent.OnChangedPinnedMsg to keep pinned messages synchronized. When an event arrives, match the conversation by conversationID, update its pinned message list, and deduplicate items using item.msg.clientMsgID. Retain the handler reference and pass it to off() during logout, account switching, or component unmounting:
import { SdkEvent } from '@openim/wasm-client-sdk';
const handlePinnedChanged = ({ data }) =>
replacePinnedMessageDetails(data.conversationID, data.msgs);
openimsdk.on(SdkEvent.OnChangedPinnedMsg, handlePinnedChanged);
const removePinnedListener = () =>
openimsdk.off(SdkEvent.OnChangedPinnedMsg, handlePinnedChanged);Was this page helpful?