Set Do Not Disturb by Channel
This document describes how to configure Do Not Disturb levels for specified channels (channelId) in Ultra Group services.
The RC 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 service segmentation (Ultra Group 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 Group only) > Default configuration for specified Ultra Group conversations (Ultra Group only) > App Key-level settings.
- User-level settings contain 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 different types of @ mentions. Starting from SDK 5.2.2, channel-specific Do Not Disturb configurations support the following levels:
| Enum Value | Numeric Value | Description |
|---|---|---|
PUSH_NOTIFICATION_LEVEL_ALL_MESSAGE | -1 | All messages trigger notifications. |
PUSH_NOTIFICATION_LEVEL_DEFAULT | 0 | Not set. This is the initial state when no configuration exists. Note: In this state, if neither the Ultra Group nor its channels have configurations, the default Do Not Disturb level for both is considered to notify all messages. |
PUSH_NOTIFICATION_LEVEL_MENTION | 1 | Only @ mention messages trigger notifications, including @ specific users and @ all members. |
PUSH_NOTIFICATION_LEVEL_MENTION_USERS | 2 | Only @ specific user messages trigger notifications, and only the mentioned users receive notifications. Example: @ Zhang San will trigger a notification for Zhang San; @ all members will not trigger notifications. |
PUSH_NOTIFICATION_LEVEL_MENTION_ALL | 4 | Only @ all members messages trigger notifications, meaning only @ all member mentions will trigger push notifications. |
PUSH_NOTIFICATION_LEVEL_BLOCKED | 5 | No notifications are received, even for @ mention messages. |
SDK versions below 5.2.2 only support setting to Do Not Disturb state (no push notifications) or reminder state (receive push notifications).
Managing Channel Do Not Disturb Settings
Ultra Groups support creating independent channels (channel) under Ultra Group conversations, aggregating message data (conversations, messages, unread counts) and group members by channel. The SDK allows users (userId) in Ultra Group services to set Do Not Disturb levels for specified group channels (channelId).
Set Channel Do Not Disturb Level (SDK ≥ 5.2.2)
This interface is available in ChannelClient starting from version 5.2.2.
The current user sets the Do Not Disturb level for messages in an Ultra Group channel.
Interface
ChannelClient.getInstance().setConversationChannelNotificationLevel(conversationType,targetId,channelId,callback);
Parameter Description
| Parameter | Type | Description |
|---|---|---|
conversationType | ConversationType | Conversation type. |
targetId | String | Conversation ID |
channelId | String | Ultra Group channel ID.
|
lev | PushNotificationLevel |
|
callback | OperationCallback | Callback interface. |
Example Code
ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";
String channelId = "Channel ID";
ChannelClient.getInstance().setConversationChannelNotificationLevel(conversationType,targetId,channelId,
IRongCoreEnum.PushNotificationLevel.PUSH_NOTIFICATION_LEVEL_DEFAULT,new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
if (callback != null) {
callback.onSuccess(notificationStatus);
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
if (callback != null) {
callback.onError(coreErrorCode);
}
}
});
Get Channel Do Not Disturb Level (SDK ≥ 5.2.2)
Retrieve the Do Not Disturb level set by the current user for an Ultra Group channel.
Interface
ChannelClient.getInstance().getConversationChannelNotificationLevel(conversationType,targetId,channelId,callback);
Parameter Description
| Parameter | Type | Description |
|---|---|---|
conversationType | [ConversationType] | Conversation type |
targetId | String | Conversation ID |
channelId | String | Ultra Group channel ID, retrieves settings for the specified channel. |
callback | ResultCallback<IRongCoreEnum.PushNotificationLevel> | Callback interface |
Example Code
ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";
String channelId = "Channel ID";
ChannelClient.getInstance().getConversationChannelNotificationLevel(conversationType,targetId,channelId,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, changes made to conversation status on other devices can be monitored in real-time on the current device. For details, see Multi-Device Do Not Disturb/Pin Synchronization.