Skip to main content

Set Do Not Disturb by Channel

This document describes how to set the Do Not Disturb level for a specified channel (channelId) in the Ultra Group business.

tip

The IM client SDK supports multi-dimensional and multi-level Do Not Disturb settings.

  • App developers can implement Do Not Disturb configurations at multiple levels, including the App Key, specified business segments (only for Ultra Groups), and user levels. When the RC server decides whether to trigger a push notification, the priority of different levels is as follows: User-level settings > Default configuration for specified Ultra Group channels (only for Ultra Groups) > Default configuration for specified Ultra Group conversations (only for Ultra Groups) > App Key-level settings.
  • User-level settings include multiple sub-dimensions. When the RC server decides whether to trigger a push notification, if user-level configurations exist, the priority of different sub-dimensions is as follows: Global Do Not Disturb > Do Not Disturb by Channel > Do Not Disturb by Conversation > Do Not Disturb by Conversation Type. For more details, see Do Not Disturb Overview.

Supported Do Not Disturb Levels

The Do Not Disturb level provides control over notifications for different @ messages. Starting from SDK 5.2.2, the Do Not Disturb configuration for specified channels supports the following levels:

Enum ValueValueDescription
PUSH_NOTIFICATION_LEVEL_ALL_MESSAGE-1All messages trigger notifications.
PUSH_NOTIFICATION_LEVEL_DEFAULT0Not set. This is the initial state when no setting is applied.

Note: In this state, if neither the Ultra Group nor the channel has a setting, the default Do Not Disturb level for the Ultra Group and channel is to notify all messages.
PUSH_NOTIFICATION_LEVEL_MENTION1Only @ messages trigger notifications, including @specific users and @all.
PUSH_NOTIFICATION_LEVEL_MENTION_USERS2Only @specific user messages trigger notifications, and only the specified user who is @mentioned will receive the notification.

For example: @张三 will trigger a notification for 张三, but @all will not trigger a notification.
PUSH_NOTIFICATION_LEVEL_MENTION_ALL4Only @all messages trigger notifications, meaning only @all messages will trigger push notifications.
PUSH_NOTIFICATION_LEVEL_BLOCKED5No notifications are received, even for @ messages.

SDK versions earlier than 5.2.2 only support setting to Do Not Disturb (no push notifications) or Remind (receive push notifications).

Managing Do Not Disturb Settings for Channels

Ultra Groups support creating independent channels (channels) under Ultra Group conversations, aggregating message data (conversations, messages, unread counts) and group members by channel. The SDK supports setting the Do Not Disturb level for specified channels (channelId) within Ultra Group business for a user (userId).

Set Do Not Disturb Level for a Specified Channel (SDK ≧ 5.2.2)

tip

This interface is available in ChannelClient and is supported starting from version 5.2.2.

Set the Do Not Disturb level for messages in a specified Ultra Group channel for the current user.

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);
}
}
});
ParameterTypeDescription
conversationTypeConversationTypeConversation type.
targetIdStringConversation ID
channelIdStringThe channel ID of the Ultra Group conversation.
  • If a channel ID is provided, the Do Not Disturb level is set for the specified channel. If no channel ID is provided, it applies to all Ultra Group messages.
  • Note: For customers who enabled Ultra Group business before 2022.09.01, if no channel ID is provided, an empty string "" is passed by default, meaning the Do Not Disturb level is set for messages in the specified Ultra Group conversation (targetId) that do not belong to any channel. To modify this, please submit a ticket.
levPushNotificationLevel
  • -1: Notify all messages
  • 0: Not set (If the user has not set this, the default setting of the group or App level applies. If not set, all messages are notified.)
  • 1: Only notify @ messages
  • 2: Only notify @specific users

    For example: @张三 will trigger a notification for 张三, but @all will not trigger a notification.

  • 4: Only notify @all messages, meaning only @all messages will trigger push notifications.
  • 5: Do not receive notifications
callbackOperationCallbackCallback interface

Get Do Not Disturb Level for a Specified Channel (SDK ≧ 5.2.2)

Get the Do Not Disturb level set for the current user in a specified Ultra Group channel.

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) {

}
});
ParameterTypeDescription
conversationTypeConversationTypeConversation type
targetIdStringConversation ID
channelIdStringThe channel ID of the Ultra Group conversation, used to get the settings for the specified channel.
callbackResultCallback<IRongCoreEnum.PushNotificationLevel>Callback interface

Multi-Device Synchronization of Do Not Disturb Status

The SDK provides a conversation status (pin or Do Not Disturb) synchronization mechanism. By setting a conversation status synchronization listener, when the conversation status is modified on another device, the change can be monitored in real-time on this device. For more details, see Synchronize Do Not Disturb/Pin Status Across Devices.