SDKsAndroid
Set global message reception
Use setSelfInfo() to set the account-wide message reception and notification policy.
Use a separate UserInfoReq for globalRecvMsgOpt so profile updates do not accidentally overwrite the account-wide message policy.
UserInfoReq request = new UserInfoReq();
request.setGlobalRecvMsgOpt(2);
OpenIMClient.getInstance().userInfoManager.setSelfInfo(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
markGlobalReceiveOptionSubmitted();
}
@Override
public void onError(int code, String error) {
recordGlobalReceiveOptionFailure(code, error);
}
},
request
);| Value | Meaning |
|---|---|
0 | Receive messages and allow notifications. |
1 | Do not receive messages. |
2 | Receive messages without notifications. |
If the product exposes only a global do-not-disturb switch, it usually toggles between 0 and 2; 1 stops message reception and should be presented as a separate option. Per-conversation reception is managed by conversation APIs and is not replaced by this setting.
A successful callback means the request completed. Reconcile the final account snapshot through onSelfInfoUpdated or getSelfLocalUserInfo(). Event handling is documented in Update the current user profile.
Was this page helpful?