Browse SDKs · Android
SDKsAndroid

Set global message reception

Use setSelfInfo() to set the account-wide message reception and notification policy.

Copy

Use UserInfoReq to set globalRecvMsgOpt.

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

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

        @Override
        public void onError(int code, String error) {
            // Handle the error.
        }
    },
    request
);
ValueMeaning
0Receive messages and allow notifications.
1Do not receive messages.
2Receive messages without notifications.

If the product exposes only a global do-not-disturb switch, it can toggle between 0 and 2; 1 stops message reception and should be presented as a separate option. Per-conversation reception is managed by conversation APIs.

A successful callback means the setting request completed.