Set Do Not Disturb by Conversation Type
This document describes how to set Do Not Disturb levels for specified conversation types (conversationType).
The IM client SDK supports multi-dimensional, multi-level Do Not Disturb settings:
- You can configure Do Not Disturb functionality across multiple dimensions: App Key level, specific business segments (ultra groups only), and user level. When the RC server determines whether to trigger push notifications, the priority of different dimensions is as follows: User-level settings > Default configuration for specified ultra group channels (ultra groups only) > Default configuration for specified ultra group conversations (ultra groups only) > App Key-level settings.
- User-level settings include multiple sub-dimensions. When the RC server determines whether to trigger push notifications (if user-level configurations exist), the priority of different sub-dimensions is as follows: Global Do Not Disturb > Channel-based Do Not Disturb > Conversation-based Do Not Disturb > Conversation Type-based Do Not Disturb. For details, see Do Not Disturb Overview.
Supported Do Not Disturb Levels
Do Not Disturb levels provide control over notifications for different types of @mentions. Starting from SDK version 5.2.2.1, the following levels are supported for conversation type-based Do Not Disturb configurations:
| Enum Value | Numeric Value | Description |
|---|---|---|
| PUSH_NOTIFICATION_LEVEL_ALL_MESSAGE | -1 | All messages trigger notifications. |
| PUSH_NOTIFICATION_LEVEL_DEFAULT | 0 | Not set (initial state when unconfigured). Note: In this state, if both ultra groups and group channels are unconfigured, their default Do Not Disturb level is considered to notify all messages. |
| PUSH_NOTIFICATION_LEVEL_MENTION | 1 | Only @mention messages trigger notifications (including @specific users and @all). |
| PUSH_NOTIFICATION_LEVEL_MENTION_USERS | 2 | Only @specific user messages trigger notifications, and only the mentioned users receive notifications. Example: @ZhangSan will trigger notifications for ZhangSan; @all will not trigger notifications. |
| PUSH_NOTIFICATION_LEVEL_MENTION_ALL | 4 | Only @all messages trigger notifications (only receives push notifications for @all mentions). |
| PUSH_NOTIFICATION_LEVEL_BLOCKED | 5 | No notifications (even @mention messages won't trigger push notifications). |
SDK versions below 5.2.2.1 only support setting to Do Not Disturb state (no push notifications) or alert state (receive push notifications).
Managing Do Not Disturb Levels by Conversation Type
Starting from SDK version 5.2.2.1, users (userId) can set Do Not Disturb levels for specified conversation types (conversationType) in IM services, supporting one-to-one chat, group chat, and ultra group conversations.
Set Do Not Disturb Level for Specified Conversation Type
This interface is available in ChannelClient starting from version 5.2.2.1.
Sets the Do Not Disturb level for a user's specified conversation type (conversationType), supporting one-to-one chat, group chat, and ultra group conversations.
Interface
ChannelClient.getInstance().setConversationTypeNotificationLevel(conversationType,lev,callback);
Parameters
| Parameter | Type | Description |
|---|---|---|
| conversationType | ConversationType | Conversation type. Chatroom type is not supported as chatrooms don't receive message alerts by default. |
| lev | PushNotificationLevel |
|
| callback | OperationCallback | Callback interface |
Example Code
ConversationType conversationType = ConversationType.PRIVATE;
ChannelClient.getInstance().setConversationTypeNotificationLevel(conversationType,
IRongCoreEnum.PushNotificationLevel.PUSH_NOTIFICATION_LEVEL_DEFAULT,new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
});
Remove Do Not Disturb Level for Specified Conversation Type
To remove the Do Not Disturb level setting for a specified conversation type, call the set interface with the lev parameter set to 0.
Query Do Not Disturb Level for Specified Conversation Type
This interface is available in ChannelClient starting from version 5.2.2.1.
Queries the current user's Do Not Disturb level setting for a specified conversation type (conversationType).
Interface
ChannelClient.getInstance().getConversationTypeNotificationLevel(conversationType, callback);
Parameters
| Parameter | Type | Description |
|---|---|---|
| conversationType | ConversationType | Conversation type |
| callback | ResultCallback<IRongCoreEnum.PushNotificationLevel> | Callback interface |
Example Code
ConversationType conversationType = ConversationType.PRIVATE;
ChannelClient.getInstance().getConversationTypeNotificationLevel(conversationType, new IRongCoreCallback.ResultCallback<
IRongCoreEnum.PushNotificationLevel>() {
@Override
public void onSuccess(IRongCoreEnum.PushNotificationLevel level) {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
}
});
Multi-Device Do Not Disturb Status Synchronization
The SDK provides a conversation status (pinned or Do Not Disturb) synchronization mechanism. By setting a conversation status synchronization listener, you can monitor real-time changes to conversation status when modified on other devices. For details, see Multi-Device Do Not Disturb/Pin Synchronization.