Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Set message receive option

Configure message reception and notification behavior for an individual conversation.

Copy

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

ParameterTypeRequiredDescription
conversationIDstringYesTarget conversation identifier.
recvMsgOptConvRecvMsgOptYesNotification policy enum value.
OptionValueDescription
ConvRecvMsgOpt.ReceiveMessage0Receive messages and display push notifications.
ConvRecvMsgOpt.NotReceiveMessage1Do not receive messages for this conversation.
ConvRecvMsgOpt.ReceiveNotNotifyMessage2Receive 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.