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.
The complete listener for SdkEvent.OnChangedPinnedMsg is provided on this page. When an event arrives, use conversationID to find the conversation, replace its pinned-message list, and deduplicate the list by item.msg.clientMsgID. Keep the handler reference and pass the same reference to off() when the user logs out, the account changes, or the SDK scope is destroyed.
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?