Skip to main content

Set Do Not Disturb by Conversation Type

This article describes how to set the Do Not Disturb level for specified conversation types (conversationType).

tip

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

  • App developers can configure Do Not Disturb functionality across multiple dimensions: App Key, specific business segments (ultra groups only), and user level. When RC's server decides whether to trigger a push notification, the priority across 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 RC's server decides whether to trigger a push notification, if user-level configurations exist, the priority across 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

Do Not Disturb levels provide control over notifications for different @ mentions. Starting from SDK version 5.2.2.1, the Do Not Disturb configuration for specified conversation types 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 no setting is applied.

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 @ mentions, including @ specific users and @ all.
PUSH_NOTIFICATION_LEVEL_MENTION_USERS2Notify only for @ specific user messages, and only the mentioned user will receive the notification.

For example: @张三, only 张三 will receive the notification; @ all will not trigger a notification.
PUSH_NOTIFICATION_LEVEL_MENTION_ALL4Notify only for @ all, meaning only @ all will trigger a notification.
PUSH_NOTIFICATION_LEVEL_BLOCKED5Do not receive notifications, even for @ mentions.

SDK versions earlier than 5.2.2.1 only support setting to Do Not Disturb state (no push notifications) or alert state (receive push notifications).

Manage Do Not Disturb Levels by Conversation Type

Starting from SDK version 5.2.2.1, users (userId) can set the Do Not Disturb level 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

tip

This API is available in ChannelClient starting from version 5.2.2.1.

Set the Do Not Disturb level for a specified conversation type (conversationType) for a user, supporting one-to-one chat, group chat, and ultra group conversations.

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

}
});
ParameterTypeDescription
conversationTypeConversationTypeConversation type. Chatroom type is not supported as chatrooms do not accept message notifications by default.
levPushNotificationLevel
  • -1: Notify for all messages
  • 0: Not set (if the user has not set this, the default setting for the group or App level will be used. If not set, all messages will be notified)
  • 1: Notify only for @ mentions
  • 2: Notify only for @ specific users

    For example: @张三, only 张三 will receive the notification; @ all will not trigger a notification.

  • 4: Notify only for @ all, meaning only @ all will trigger a notification.
  • 5: Do not receive notifications
callbackOperationCallbackCallback interface

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 and pass 0 for the lev parameter.

Query Do Not Disturb Level for Specified Conversation Type

tip

This API is available in ChannelClient starting from version 5.2.2.1.

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

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

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

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