Browse SDKs · WASM
SDKsWASMEnterprise

Pin or unpin a message

Pin or unpin one message with the WASM SDK.

Copy

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesID of the conversation containing the message.
clientMsgIDstringYesID of the message to pin or unpin.
pinnedbooleanYestrue 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);