Set Do Not Disturb by Conversation
This document describes how to set the Do Not Disturb level for a specified conversation (targetId
).
The Instant Messaging client SDK supports multi-dimensional and multi-level Do Not Disturb settings.
- App developers can implement Do Not Disturb configurations at multiple levels, including App Key, specific business segments (only for ultra groups), and user levels. When RC's 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 (only supported for ultra groups) > Default configuration for specified ultra group conversations (only supported for ultra groups) > App Key-level settings.
- User-level settings include multiple dimensions. When RC's 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 more details, refer to Do Not Disturb Overview.
When Do Not Disturb is active, the client behavior upon receiving new messages is as follows:
- Client running in the background: When there is a new message in the conversation, the message content can be received. You need to implement the local notification pop-up yourself.
- Client offline: When there is a new message in the conversation, no remote notification reminder will be received. The message content can be retrieved upon reconnection.
Supported Do Not Disturb Levels
Do Not Disturb levels provide control over different @ message notifications. Starting from SDK 5.2.2, the Do Not Disturb configuration for specified conversations supports the following levels:
Enum Value | Value | Description |
---|---|---|
RCPushNotificationLevelAllMessage | -1 | All messages can trigger notifications. |
RCPushNotificationLevelDefault | 0 | Not set. This is the initial state when no setting is applied. 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 considered to be all messages triggering notifications. |
RCPushNotificationLevelMention | 1 | Only @ messages trigger notifications, including @specific users and @all. |
RCPushNotificationLevelMentionUsers | 2 | Only @specific user messages trigger notifications, and only the specified @ users receive notifications. For example: @张三, then 张三 can receive the push; @all will not trigger a push notification. |
RCPushNotificationLevelMentionAll | 4 | Only @all messages trigger notifications, i.e., only @all push notifications are received. |
RCPushNotificationLevelBlocked | 5 | No notifications are received, even for @ messages. |
SDK versions earlier than 5.2.2 only support setting to Do Not Disturb state (no push notifications) or reminder state (receive push notifications).
Manage Do Not Disturb Settings for Conversations
Instant Messaging 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 RCChannelClient
starting from version 5.2.2.
Set the Do Not Disturb level for the specified conversation (targetId
) for the current user.
[[RCChannelClient sharedChannelManager] setConversationNotificationLevel:"Conversation Type"
targetId:"Conversation Id"
level:RCPushNotificationLevelDefault
success:^() {}
error:^(RCErrorCode status) {}];
Parameter | Type | Description |
---|---|---|
conversationType | RCConversationType | Conversation type. Note the following limitations:
|
targetId | NSString | Conversation ID |
level | RCPushNotificationLevel |
|
successBlock | block | Callback interface |
errorBlock | block | 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 setting interface and pass RCPushNotificationLevelDefault
for the level
parameter.
Query Do Not Disturb Level for a Specified Conversation (SDK >= 5.2.2)
This interface is available in RCChannelClient
starting from version 5.2.2.
Query the Do Not Disturb level set by the current user for the specified conversation (targetId
).
[[RCChannelClient sharedChannelManager] getConversationNotificationLevel: "Conversation Type"
targetId: "Conversation Id"
success:^(RCPushNotificationLevel level) {}
error:^(RCErrorCode status) {}];
Parameter | Type | Description |
---|---|---|
conversationType | RCConversationType | Conversation type |
targetId | String | Conversation Id |
successBlock | block | Callback interface |
errorBlock | block | Callback interface |
Get Do Not Disturb Status List
This interface is available in RCIMClient
.
Get all conversations with Do Not Disturb enabled. The returned RCConversation list does not include specific Do Not Disturb level information or channel information.
NSArray *array = [[RCIMClient sharedRCIMClient] getBlockedConversationList:@[@(ConversationType_PRIVATE)]];
Parameter | Type | Description |
---|---|---|
conversationTypeList | NSArray | Array of conversation types, convert RCConversationType to NSNumber to build the Array |