Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Set global message reception

Configure the account-wide default message receiving and notification option.

Copy

The globalRecvMsgOpt field governs the account-wide default notification policy, operating independently of user nicknames or avatars. Standard interfaces provide the following two options:

Code example

import sdk, { GlobalRecvMsgOpt, SetSelfInfoReq } from '@openimsdk/imsdk';

const request: SetSelfInfoReq = {
  userID: currentUserID,
  globalRecvMsgOpt: GlobalRecvMsgOpt.NotNotify,
};
await sdk.setSelfInfo(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesSigned-in user identifier.
globalRecvMsgOptGlobalRecvMsgOptYesGlobal notification preference enum value.
OptionValueDescription
GlobalRecvMsgOpt.Normal0Normal message reception with push notifications.
GlobalRecvMsgOpt.NotNotify2Receive messages silently without notifications (account-wide DND).

To disable global DND, reset the property back to GlobalRecvMsgOpt.Normal.

Return value

Returns a Promise that resolves to void when the setting is updated.

State changes after the call

Per-conversation reception settings provide finer granularity; see Set message receive option. When both global and conversation settings exist, evaluate the final delivery behavior from the conversation's recvMsgOpt. After the Promise resolves, await EventOnSelfInfoUpdated or re-query via Retrieve current user profile.