Set Do Not Disturb by Conversation
This document describes how to set the Do Not Disturb level for a specified conversation (targetId
).
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 Value | Value | Description |
---|---|---|
PUSH_NOTIFICATION_LEVEL_ALL_MESSAGE | -1 | Notify for all messages. |
PUSH_NOTIFICATION_LEVEL_DEFAULT | 0 | Not 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_MENTION | 1 | Notify only for @ messages, including @specific users and @all. |
PUSH_NOTIFICATION_LEVEL_MENTION_USERS | 2 | Notify 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_ALL | 4 | Notify only for @all messages, i.e., only receive push notifications for @all. |
PUSH_NOTIFICATION_LEVEL_BLOCKED | 5 | Do 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)
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) {
}
});
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | Conversation type. Please note the following restrictions:
|
targetId | String | Conversation ID |
level | PushNotificationLevel |
|
callback | OperationCallback | Callback 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)
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) {
});
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | Conversation type |
targetId | String | Conversation ID |
callback | ResultCallback<IRongCoreEnum.PushNotificationLevel> | Callback interface |
Get Do Not Disturb Status List
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);
Parameter | Type | Description |
---|---|---|
callback | ResultCallback<List<Conversation>> | Callback interface |
conversationTypes | ConversationType ... | 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.