Skip to main content

Set Do Not Disturb

This document describes how to configure Do Not Disturb for a specified conversation (Target ID). Once a conversation or specific messages are set to Do Not Disturb, if the mobile platform client is offline, it will not receive remote notifications.

The Do Not Disturb configuration for a conversation will be synchronized to the server. RC automatically synchronizes the Do Not Disturb configuration data across devices for users. Clients can receive synchronization notifications via listeners or actively fetch the latest data.

Using Do Not Disturb Levels (SDK ≧ 5.3.0)

tip
  • Starting from SDK 5.3.0, Do Not Disturb level configuration (notificationLevel) is provided, allowing apps to implement granular notification control strategies. Android/iOS mobile platforms have supported Do Not Disturb levels since SDK 5.2.2.
  • If your application is based on the Electron solution, Do Not Disturb levels (notificationLevel) are not currently supported. Please use the Do Not Disturb status configuration (notificationStatus). For details, see Using Do Not Disturb Status.

Given the inherent business characteristics of instant messaging, apps may need to implement granular notification control strategies. Currently, the Web IMLib SDK supports multi-dimensional, multi-level Do Not Disturb settings.

  • Supports Do Not Disturb configurations at the App Key level, specific business segments (ultra groups only), and user levels. When RC's server decides whether to trigger push notifications, the priority of 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 refer to Do Not Disturb configurations that can be controlled by app users, including multiple granular dimensions. When RC's server decides whether to trigger push notifications, if user-level configurations exist, the priority of different granular dimensions is as follows: Global Do Not Disturb > Channel-based Do Not Disturb > Conversation-based Do Not Disturb. For details, see Do Not Disturb Overview.
  • Customers using ultra group services should refer to the documents under Ultra Group Management: "Setting Default Do Not Disturb for Groups/Channels" and "Setting Do Not Disturb for Specified Groups/Channels".

The Do Not Disturb level (notificationLevel) provides control over Do Not Disturb for different @ messages. Starting from SDK 5.3.0, the following levels are supported for Do Not Disturb configuration:

Enumeration Value of notificationLevelValueDescription
NotificationLevel.ALL_MESSAGE-1Notifications are received for all messages, i.e., Do Not Disturb is turned off.
NotificationLevel.NOT_SET0Not set (this is the default state when the user has not set it, meaning notifications are received for all messages; in this state, if the default state of an ultra group is set, the ultra group's default setting will take precedence).
NotificationLevel.AT_MESSAGE_NOTIFICATION1Notifications are only triggered for @ messages, including @ specific users and @ all.
NotificationLevel.AT_USER_NOTIFICATION2Notifications are only triggered for @ specific user messages, and only the specified user who is @ed will receive the notification.
For example: @张三 will trigger a notification for Zhang San, but @所有人 will not trigger a notification.
NotificationLevel.AT_GROUP_ALL_USER_NOTIFICATION4Notifications are only triggered for @ all group members, and only @ all will trigger a notification.
NotificationLevel.NOT_MESSAGE_NOTIFICATION5No notifications are received, even for @ messages.

Setting Do Not Disturb Levels

tip

The Web platform has supported the setConversationNotificationLevel interface since 5.3.0, and the setConversationNotificationStatus interface has been deprecated. The Electron platform has supported the setConversationNotificationLevel interface since version 5.8.4.

Call setConversationNotificationLevel to set the Do Not Disturb level.

const conversationType = RongIMLib.ConversationType.GROUP;
const targetId = 'Target ID';
const notificationLevel = RongIMLib.NotificationLevel.NOT_MESSAGE_NOTIFICATION

RongIMLib.setConversationNotificationLevel({
conversationType,
targetId,
}, notificationLevel).then(( {code} ) => {
// Successfully set the Do Not Disturb status
})
ParameterTypeRequiredDescription
targetIdStringYesTarget ID
conversationTypeNumberYesConversation type. Refer to ConversationType.
notificationLevelNumberYesDo Not Disturb level. For details, see the description of notificationLevel in the Supported Do Not Disturb Levels section above.

Getting Do Not Disturb Levels

tip

The getConversationNotificationLevel interface has been supported since 5.3.0, and the setConversationNotificationStatus interface has been deprecated.

Call getConversationNotificationLevel to get the Do Not Disturb level.

ParameterTypeRequiredDescription
targetIdStringYesTarget ID
conversationTypeNumberYesConversation type. Refer to ConversationType.
const conversationType = RongIMLib.ConversationType.GROUP;
const targetId = 'Target ID';

RongIMLib.getConversationNotificationLevel({
conversationType,
targetId,
}).then(({ code, data }) => {

})

Using Do Not Disturb Status (For Electron)

tip
  • If you are implementing a Web application and the SDK version is < 5.3.0, you can use the notificationStatus related interfaces. If the SDK version is ≧ 5.3.0, it is recommended to use the Do Not Disturb Levels feature.
  • If your application is based on the Electron solution, only the following interfaces for setting the Do Not Disturb status (notificationStatus) are currently supported. Configuring Do Not Disturb levels is not supported.

The SDK supports setting the Do Not Disturb status (notificationStatus) for conversations, with two states supported.

ValueDescription
NotificationStatus.OPENDo Not Disturb is enabled (no push notifications are received).
NotificationStatus.CLOSEDo Not Disturb is disabled (push notifications are received).

Apps can call setConversationNotificationStatus to set the Do Not Disturb status. Call getConversationNotificationStatus to query the Do Not Disturb status.

const conversationType = RongIMLib.ConversationType.PRIVATE;
const targetId = 'Receiver's userId';
const notificationStatus = NotificationStatus.OPEN

// Set the conversation to Do Not Disturb status
RongIMLib.setConversationNotificationStatus({
conversationType,
targetId,
}, notificationStatus).then(( {code} ) => {
// Successfully set the Do Not Disturb status
if( !code ){

}
})

// Get the Do Not Disturb status of the conversation
RongIMLib.getConversationNotificationStatus({
conversationType,
targetId,
}).then(({ code, data }) => {

})
ParameterTypeRequiredDescription
targetIdStringYesReceiver's userId
conversationTypeNumberYesConversation type. Refer to ConversationType.
notificationStatusNumberNoDo Not Disturb status.

Getting the Do Not Disturb Conversation List

tip

This interface has been supported since 5.1.1.

Call getBlockedConversationList to get all conversations that have been set to Do Not Disturb status.

RongIMLib.getBlockedConversationList().then(( {code, data} ) => {
// Successfully retrieved the Do Not Disturb conversations
if( code === RongIMLib.ErrorCode.SUCCESS ){
console.log("blocked conversation list",data)
}
})