Skip to main content

Set Do Not Disturb by Conversation

This document describes how to set the Do Not Disturb level for a specified conversation (targetId).

tip

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

  • App developers can configure Do Not Disturb functionality at multiple levels: App Key, specified business segments (ultra groups only), and user level. When RC server decides whether to trigger push notifications, the priority of different levels 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 dimensions. When RC server decides whether to trigger push notifications, if user-level configurations exist, the priority of different 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 details, see Do Not Disturb Overview.

Supported Do Not Disturb Levels

Do Not Disturb levels provide control over notifications for different @ messages. Starting from SDK 5.2.2, the Do Not Disturb configuration for specified conversations supports the following levels:

Enum ValueValueDescription
PUSH_NOTIFICATION_LEVEL_ALL_MESSAGE-1Notify for all messages.
PUSH_NOTIFICATION_LEVEL_DEFAULT0Not set. This is the initial state when not set.

Note: In this state, if both the ultra group and group channel are not set, the default Do Not Disturb level for the ultra group and channel is to notify for all messages.
PUSH_NOTIFICATION_LEVEL_MENTION1Notify only for @ messages, including @specific users and @all.
PUSH_NOTIFICATION_LEVEL_MENTION_USERS2Notify only for @specific user messages, and only notify the specified user who is @mentioned.

For example: @ZhangSan, ZhangSan will receive the push; @all will not trigger a push notification.
PUSH_NOTIFICATION_LEVEL_MENTION_ALL4Notify only for @all messages, i.e., only receive push notifications for @all.
PUSH_NOTIFICATION_LEVEL_BLOCKED5Do not receive notifications, even for @ messages.

SDK versions earlier than 5.2.2 only support setting to Do Not Disturb state (do not receive push notifications) or reminder state (receive push notifications).

Manage Do Not Disturb Settings for Conversations

IM business users (userId) can set the Do Not Disturb level for specified conversations (targetId), supporting one-to-one chat, group chat, and ultra group conversations.

Set Do Not Disturb Level for a Specified Conversation (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 a specified conversation (targetId) for the current user.

ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";

ChannelClient.getInstance().setConversationNotificationLevel(conversationType,targetId,
IRongCoreEnum.PushNotificationLevel.PUSH_NOTIFICATION_LEVEL_DEFAULT,new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});
ParameterTypeDescription
conversationTypeConversationTypeConversation type. Please note the following restrictions:
  • Ultra Group Conversation Type: If the ultra group service was activated before 2022.09.01, by default, it does not support setting the Do Not Disturb level for all messages of a single ultra group conversation ("all messages" refer to messages in all channels and messages not belonging to any channel). This interface only sets the Do Not Disturb level for messages not belonging to any channel in the specified ultra group conversation (targetId). To modify this, please submit a ticket.
  • Chatroom Conversation Type: Not supported, as chatroom messages do not support push notifications by default.
targetIdStringConversation ID
levelPushNotificationLevel
  • -1: Notify for all messages
  • 0: Not set (if the user does not set, the default is based on the group or APP level default settings, if not set, all messages are notified)
  • 1: Notify only for @ messages
  • 2: Notify only for @specific users

    For example: @ZhangSan will trigger a push for ZhangSan, @all will not trigger a push.

  • 4: Notify only for @all messages, only receive push notifications for @all.
  • 5: Do not receive notifications
callbackOperationCallbackCallback interface

Remove Do Not Disturb Level for a Specified Conversation (SDK >= 5.2.2)

To remove the Do Not Disturb setting for a specified conversation type, call the set interface and pass 0 for the level parameter.

Query Do Not Disturb Level for a Specified Conversation (SDK >= 5.2.2)

tip

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

Query the Do Not Disturb level set by the current user for a specified conversation (targetId).

ConversationType conversationType = ConversationType.PRIVATE;
String targetId = "Conversation ID";

ChannelClient.getInstance().getConversationChannelNotificationLevel(conversationType, targetId, new IRongCoreCallback.ResultCallback<
IRongCoreEnum.PushNotificationLevel>() {
@Override
public void onSuccess(IRongCoreEnum.PushNotificationLevel level) {

}
}

@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {

});
ParameterTypeDescription
conversationTypeConversationTypeConversation type
targetIdStringConversation ID
callbackResultCallback<IRongCoreEnum.PushNotificationLevel>Callback interface

Get Do Not Disturb Status List

tip

This interface is available in RongIMClient.

Get all conversations with Do Not Disturb enabled. The returned conversation list does not include specific Do Not Disturb level information or channel information.

Conversation.ConversationType[] conversationTypes = {ConversationType.PRIVATE, ConversationType.GROUP};

RongIMClient.getInstance().getBlockedConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {

@Override
public void onSuccess(List<Conversation> conversations) {

}

@Override
public void onError(RongIMClient.ErrorCode errorCode) {

}
}, conversationTypes);
ParameterTypeDescription
callbackResultCallback<List<Conversation>>Callback interface
conversationTypesConversationType ...Conversation type array, multiple conversation types can be set (chatrooms are not supported).

Sync Do Not Disturb Status Across Devices

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 details, see Sync Do Not Disturb/Pin Status Across Devices.