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

Set message receive option

Configure message reception and notification behavior for a specific conversation.

Copy

The recvMsgOpt property controls message reception and alerting for an individual conversation, commonly used to implement per-chat Do Not Disturb (DND) or muting.

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesIdentifier of the target conversation.
recvMsgOptOpenIMMessageReceiveOptionYesTarget message reception policy enum.

Message receive options

Enum valueNumeric valueDescription
OpenIMMessageReceiveOptionReceive0Receive messages normally and trigger notifications.
OpenIMMessageReceiveOptionDoNotReceive1Block and reject incoming messages for this conversation.
OpenIMMessageReceiveOptionReceiveWithoutNotification2Receive incoming messages silently without sound or notification alerts (Mute).

Code example

import {
  OpenIMMessageReceiveOptionReceiveWithoutNotification,
  setConversation,
} from '@/uni_modules/unix-openim-sdk'

await setConversation({
  conversationID,
  recvMsgOpt: OpenIMMessageReceiveOptionReceiveWithoutNotification,
})

Conversation-level reception options operate independently from the global user notification policy configured in Set global message reception.

Return value

The Promise resolves with void upon successful completion.

State changes after the call

Promise resolution, conversation change event arrival, and re-querying the conversation are three distinct lifecycle stages. Update your local state optimistically or wait for onConversationChanged, merging the updated recvMsgOpt by conversationID. For the centralized conversation listener implementation, see Retrieve conversation list.