SDKsAndroid
Set global message reception
Configure account-level message reception and notification rules across all conversations.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
request | UserInfoReq | Yes | User profile request payload containing the global reception mode integer code. |
Message reception modes
| Enum constant | Value | Description |
|---|---|---|
ReceiveMessageOpt.Normal | 0 | Receive messages normally with local alerts and push notifications. |
ReceiveMessageOpt.NotReceive | 1 | Block incoming messages entirely across all chats. |
ReceiveMessageOpt.NotNotify | 2 | Receive 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
- Callback confirmation: The
onSuccesscallback indicates that the server recorded the global reception setting. If your application exposes a simple "Mute all notifications" toggle, switch between0and2; mode1rejects incoming messages entirely and should be treated as a distinct privacy option. - Asynchronous event delivery: The current account receives the
OnUserListener.onSelfInfoUpdatedevent containing the updated user profile with the new global message reception option. - 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.
Was this page helpful?