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.
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 Value | 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 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_MENTION | 1 | Only @ messages trigger notifications, including @specific users and @all. |
PUSH_NOTIFICATION_LEVEL_MENTION_USERS | 2 | Only @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_ALL | 4 | Only @all messages trigger notifications, meaning only @all messages will trigger push notifications. |
PUSH_NOTIFICATION_LEVEL_BLOCKED | 5 | No 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)
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);
}
}
});
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | Conversation type. |
targetId | String | Conversation ID |
channelId | String | The channel ID of the Ultra Group conversation.
|
lev | PushNotificationLevel |
|
callback | OperationCallback | Callback 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) {
}
});
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | The channel ID of the Ultra Group conversation, used to get the settings for the specified channel. |
callback | ResultCallback<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.