Browse SDKs · Android
Platform
SDKsAndroid

Set global message reception

Configure account-level message reception and notification rules across all conversations.

Copy

Configure account-wide message reception and do-not-disturb (DND) policies that apply universally across all direct and group conversations.

Set the global option integer code in the user configuration request, then submit it via Update the current user profile:

Code example

UserInfoReq request = new UserInfoReq();
request.setGlobalRecvMsgOpt(2);

OpenIMClient.getInstance().userInfoManager.setSelfInfo(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Global message reception option configured successfully
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    },
    request
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
requestUserInfoReqYesUser profile request payload containing the global reception mode integer code.

Message reception modes

Enum constantValueDescription
ReceiveMessageOpt.Normal0Receive messages normally with local alerts and push notifications.
ReceiveMessageOpt.NotReceive1Block incoming messages entirely across all chats.
ReceiveMessageOpt.NotNotify2Receive messages silently without sound, vibration, or push notifications (global DND).

Return value

Upon success, data in onSuccess returns a confirmation message.

State changes after the call

  1. Callback confirmation: The onSuccess callback indicates that the server recorded the global reception setting. If your application exposes a simple "Mute all notifications" toggle, switch between 0 and 2; mode 1 rejects incoming messages entirely and should be treated as a distinct privacy option.
  2. Asynchronous event delivery: The current account receives the OnUserListener.onSelfInfoUpdated event containing the updated user profile with the new global message reception option.
  3. Re-query calibration: To verify or reload current account settings, call Get current user profile. For per-conversation message reception overrides, see Set conversation message reception.