SDKsHarmonyOSEnterprise
Set message receive option
Configure message reception and notification behavior for an individual conversation.
Use recvMsgOpt to configure the notification and message delivery behavior for a specific conversation, commonly used for per-chat Do Not Disturb (DND):
Code example
import sdk, { ConvRecvMsgOpt, SetConversationReq } from '@openimsdk/imsdk';
const request: SetConversationReq = {
conversationID: conversationID,
recvMsgOpt: ConvRecvMsgOpt.ReceiveNotNotifyMessage,
};
await sdk.setConversation(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
recvMsgOpt | ConvRecvMsgOpt | Yes | Notification policy enum value. |
| Option | Value | Description |
|---|---|---|
ConvRecvMsgOpt.ReceiveMessage | 0 | Receive messages and display push notifications. |
ConvRecvMsgOpt.NotReceiveMessage | 1 | Do not receive messages for this conversation. |
ConvRecvMsgOpt.ReceiveNotNotifyMessage | 2 | Receive messages silently without alerting the user (Do Not Disturb). |
To configure the account-level default policy, see Set global message reception.
Return value
Returns a Promise that resolves to void when the option is updated.
State changes after the call
Once the Promise resolves, the SDK emits EventOnConversationChanged. Match the item by conversationID and update its recvMsgOpt property in your UI model, as documented in Retrieve conversation list.
Was this page helpful?