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.
This page is the sole owner of CbEvents.OnChangedPinnedMsg. Replace the pinned set by conversationID and deduplicate it by item.msg.clientMsgID. Register a stable handler reference and call off() with that same reference when the account scope ends.
const handlePinnedChanged = ({ data }) =>
replacePinnedMessageDetails(data.conversationID, data.msgs);
openimsdk.on(CbEvents.OnChangedPinnedMsg, handlePinnedChanged);
const removePinnedListener = () =>
openimsdk.off(CbEvents.OnChangedPinnedMsg, handlePinnedChanged);Was this page helpful?