Skip to main content

Set Do Not Disturb by Conversation

This document describes how to set Do Not Disturb levels for specified conversations (targetId).

tip

The IM Client SDK supports multi-dimensional, multi-level Do Not Disturb settings:

  • App developers can configure Do Not Disturb functionality across multiple dimensions: App Key level, specific business segments (ultra groups only), and user level. When the RC server determines 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 include multiple sub-dimensions. When the RC server determines whether to trigger push notifications (if user-level configurations exist), the priority of different sub-dimensions is as follows: Global Do Not Disturb > Channel-based Do Not Disturb > Conversation-based Do Not Disturb > Conversation-type-based Do Not Disturb. For details, see Do Not Disturb Overview.

Supported Do Not Disturb Levels

Do Not Disturb levels provide control over different types of @ mentions. Starting from SDK 5.2.2, the following levels are supported for conversation-specific Do Not Disturb configurations:

Enum ValueNumeric ValueDescription
RCPushNotificationLevelAllMessage-1Notifications enabled for all messages.
RCPushNotificationLevelDefault0Not set (initial state).

Note: In this state, if both ultra group and channel settings are unset, the default Do Not Disturb level for ultra groups and channels is considered to be "notify for all messages".
RCPushNotificationLevelMention1Notify only for @ mentions, including @specific users and @all
RCPushNotificationLevelMentionUsers2Notify only for @specific user mentions, and only notify the specifically mentioned users.

Example: @ZhangSan will trigger a notification for ZhangSan; @all will not trigger notifications.
RCPushNotificationLevelMentionAll4Notify only for @all mentions (group-wide notifications).
RCPushNotificationLevelBlocked5No notifications, even for @ mentions.

SDK versions below 5.2.2 only support setting to Do Not Disturb state (no push notifications) or reminder state (receive push notifications).

Managing Conversation Do Not Disturb Settings

IM users (userId) can set Do Not Disturb levels for specified conversations (targetId), supporting one-to-one chats, group chats, and ultra group conversations.

Set Do Not Disturb Level for Specified Conversation (SDK ≥ 5.2.2)

tip

This interface is available in the RCChannelClient class, supported from version 5.2.2.

Set the Do Not Disturb level for a specified conversation (targetId) for the current user.

Interface Prototype

- (void)setConversationNotificationLevel:(RCConversationType)conversationType
targetId:(NSString *)targetId
level:(RCPushNotificationLevel)level
success:(nullable void (^)(void))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;

Parameter Description

ParameterTypeDescription
conversationTypeRCConversationTypeConversation type. Note the following restrictions:
  • Ultra Group Conversation Type: For ultra group services activated before 2022.09.01, setting Do Not Disturb levels for all messages in a single ultra group conversation ("all messages" refers to messages across all channels and messages not belonging to any channel) is not supported by default. This interface only sets the Do Not Disturb level for messages in the specified ultra group conversation (targetId) that do not belong to any channel. Submit a ticket to modify this.
  • Chatroom Conversation Type: Not supported, as chatroom messages do not support push notifications by default.
targetIdNSStringConversation ID
levelRCPushNotificationLevel
  • -1: Notify for all messages
  • 0: Not set (if unset by user, defaults to group or App-level settings; if unset at those levels, all messages are notified)
  • 1: Notify only for @ mentions
  • 2: Notify only for @specific user mentions

    Example: @ZhangSan will trigger a notification for ZhangSan; @all will not trigger notifications.

  • 4: Notify only for @all mentions (group-wide notifications)
  • 5: No notifications
successBlockblockCallback interface
errorBlockblockCallback interface

Example Code

[[RCChannelClient sharedChannelManager] setConversationNotificationLevel:"Conversation Type"
targetId:"Conversation Id"
level:RCPushNotificationLevelDefault
success:^() {}
error:^(RCErrorCode status) {}];

Remove Do Not Disturb Level for Specified Conversation (SDK ≥ 5.2.2)

To remove the Do Not Disturb setting for a specified conversation type, call the set interface with the level parameter set to RCPushNotificationLevelDefault.

Query Do Not Disturb Level for Specified Conversation (SDK ≥ 5.2.2)

tip

This interface is available in the RCChannelClient class, supported from version 5.2.2.

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

Interface Prototype

- (void)getConversationNotificationLevel:(RCConversationType)conversationType
targetId:(NSString *)targetId
success:(nullable void (^)(RCPushNotificationLevel level))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;

Parameter Description

ParameterTypeDescription
conversationTypeRCConversationTypeConversation type
targetIdStringConversation targetId
successBlockblockCallback interface
errorBlockblockCallback interface

Example Code

[[RCChannelClient sharedChannelManager] getConversationNotificationLevel:"Conversation Type"
targetId:"Conversation Id"
success:^(RCPushNotificationLevel level) {}
error:^(RCErrorCode status) {}];

Get Do Not Disturb Status List

tip

This interface is available in the RCCoreClient class.

Get all conversations with Do Not Disturb enabled. Returns a list of RCConversation objects.

Interface Prototype

- (void)getBlockedConversationList:(NSArray<NSNumber *> *)conversationTypeList
completion:(nullable void(^)(NSArray<RCConversation *> *_Nullable conversationList))completion;

Parameter Description

ParameterTypeDescription
conversationTypeListNSArrayArray of conversation types (convert RCConversationType to NSNumber to build the array).
completionBlockQuery result callback, returns a list of RCConversation objects.

Interface Call

[[RCCoreClient sharedCoreClient] getBlockedConversationList:@[@(ConversationType_PRIVATE)] completion:^(NSArray<RCConversation *> *_Nullable conversationList) {

}];

Multi-Device Do Not Disturb Status Synchronization

The SDK provides a conversation status (pinned or Do Not Disturb) synchronization mechanism. By setting up a conversation status synchronization listener, you can monitor real-time changes to conversation status when modified on other devices. For details, see Multi-Device Do Not Disturb/Pinned Status Synchronization.