Set Do Not Disturb by Conversation
This document describes how to set Do Not Disturb levels for specified conversations (targetId).
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 Value | Numeric Value | Description |
|---|---|---|
| RCPushNotificationLevelAllMessage | -1 | Notifications enabled for all messages. |
| RCPushNotificationLevelDefault | 0 | Not 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". |
| RCPushNotificationLevelMention | 1 | Notify only for @ mentions, including @specific users and @all |
| RCPushNotificationLevelMentionUsers | 2 | Notify 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. |
| RCPushNotificationLevelMentionAll | 4 | Notify only for @all mentions (group-wide notifications). |
| RCPushNotificationLevelBlocked | 5 | No 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)
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
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type. Note the following restrictions:
|
| targetId | NSString | Conversation ID |
| level | RCPushNotificationLevel |
|
| successBlock | block | Callback interface |
| errorBlock | block | Callback 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)
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
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type |
| targetId | String | Conversation targetId |
| successBlock | block | Callback interface |
| errorBlock | block | Callback interface |
Example Code
[[RCChannelClient sharedChannelManager] getConversationNotificationLevel:"Conversation Type"
targetId:"Conversation Id"
success:^(RCPushNotificationLevel level) {}
error:^(RCErrorCode status) {}];
Get Do Not Disturb Status List
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
| Parameter | Type | Description |
|---|---|---|
| conversationTypeList | NSArray | Array of conversation types (convert RCConversationType to NSNumber to build the array). |
| completion | Block | Query 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.