Browse SDKs · uni-app / uni-app x
SDKsuni-appEnterprise

Pin or unpin a message

OpenIM uni-app / uni-app x SDK guide for Pin or unpin a message.

Copy

setConversationPinnedMsg() and onChangedPinnedMsg are Commercial.

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation containing the message.
clientMsgIDstringYesMessage to pin or unpin.
pinnedbooleanYestrue to pin, false to unpin.
import { off, onChangedPinnedMsg, setConversationPinnedMsg } from '@/uni_modules/unix-openim-sdk'

const pinnedSubscription = onChangedPinnedMsg((payload) => refreshPinnedMessagesAfterValidJson(payload))
await setConversationPinnedMsg({ conversationID, clientMsgID: message.clientMsgID, pinned: true })

function removePinnedListener() {
  off(pinnedSubscription)
}

The server enforces permission, message-type, and count limits. Promise success does not mean the event arrived. This page owns the raw JSON onChangedPinnedMsg event. Validate it, refresh the conversation's pinned set, and deduplicate by clientMsgID rather than casting opaque JSON directly to a message. Remove the subscription when the login scope ends.