SDKsuni-appEnterprise
Pin or unpin a message
OpenIM uni-app / uni-app x SDK guide for Pin or unpin a message.
setConversationPinnedMsg() and onChangedPinnedMsg are Commercial.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Conversation containing the message. |
clientMsgID | string | Yes | Message to pin or unpin. |
pinned | boolean | Yes | true 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.
Was this page helpful?