Set Conversation Do Not Disturb
- This document only describes the method of setting Do Not Disturb using
RCIMClient
interfaces when the SDK version is < 5.2.2.- For SDK versions ≧ 5.2.2, we recommend using the global Do Not Disturb interface under
RCChannelClient
that supports setting Do Not Disturb levels. Refer to the IMLib documentation Set Do Not Disturb by Target ID.
The IM service supports Do Not Disturb settings for conversations. The IMKit SDK allows you to set message alert status to "Do Not Disturb" based on conversation type and conversation ID. When enabled, if the client runs in the background, new messages in the conversation won't trigger notifications (though message content will still be received). If the client is offline, remote notifications won't be delivered.
The Do Not Disturb status of conversations is synchronized with the server. RC automatically syncs conversation Do Not Disturb status data across devices. Clients can receive sync notifications through listeners or actively fetch the latest data.
Set Conversation Do Not Disturb Status (< 5.2.2)
The RCIMClient
class provides the setConversationNotificationStatus
method to set message alert status to "Do Not Disturb" based on conversation type and conversation ID. After successful setup, clients won't receive new message notifications for this conversation when running in the background or offline. You can manually refresh the UI by fetching updated data sources.
The IMKit SDK doesn't directly provide this method—you'll need to use the IMLib method for getting conversation Do Not Disturb status.
[[RCIMClient sharedRCIMClient] setConversationNotificationStatus:ConversationType_PRIVATE
targetId:self.userId
isBlocked:YES
success:^(RCConversationNotificationStatus nStatus) {}
error:^(RCErrorCode status){}];
Parameter | Type | Description |
---|---|---|
conversationType | RCConversationType | Conversation type. For one-to-one chat, use ConversationType_PRIVATE |
targetId | NSString | Conversation ID |
isBlocked | BOOL | Whether to mute message alerts |
successBlock | BOOL | Success callback |
errorBlock | BOOL | Failure callback. The status parameter contains error codes (see RCErrorCode). |
Monitor Conversation Do Not Disturb Status Sync
The IM service supports conversation status sync mechanisms (including pinned status and Do Not Disturb status data). After setting up a conversation status sync listener, you'll receive notifications when conversation status changes.
When conversation pinned/Do Not Disturb status data syncs, the SDK dispatches this notification:
FOUNDATION_EXPORT NSString *const RCKitDispatchConversationStatusChangeNotification;
The notification's object is an array of RCConversationStatusInfo
objects, with userInfo
as nil.
Register the notification listener:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onConversationStatusChanged:)
name:RCKitDispatchConversationStatusChangeNotification
object:nil];
Update your conversation status upon receiving the notification:
- (void)onConversationStatusChanged:(NSNotification *)notification {
NSArray<RCConversationStatusInfo *> *conversationStatusInfos = notification.object;
}
Get Conversation Do Not Disturb Status (< 5.2.2)
Clients can actively fetch the latest conversation Do Not Disturb status data.
The IMKit SDK doesn't directly provide this method—use the IMLib method for getting conversation Do Not Disturb status.
[[RCIMClient sharedRCIMClient] getConversationNotificationStatus:ConversationType_PRIVATE
targetId:self.userId
success:^(RCConversationNotificationStatus nStatus) {}
error:^(RCErrorCode status){}];
Parameter | Type | Description |
---|---|---|
conversationType | RCConversationType | Conversation type. For one-to-one chat, use ConversationType_PRIVATE |
targetId | NSString | Conversation ID |
success | BOOL | Success callback. The nStatus parameter indicates the conversation's message alert status (see RCConversationNotificationStatus). |
error | BOOL | Failure callback. The status parameter contains error codes (see RCErrorCode). |
Get Do Not Disturb Conversation List (< 5.2.2)
Retrieve all conversations with Do Not Disturb enabled. The returned list doesn't include specific Do Not Disturb level information or channel details.
The IMKit SDK doesn't directly provide this method—use the IMLib method for getting conversation Do Not Disturb status.
NSArray *array = [[RCIMClient sharedRCIMClient] getBlockedConversationList:@[@(ConversationType_PRIVATE)]];
Parameter | Type | Description |
---|---|---|
conversationTypeList | NSArray | An array of conversation types. Convert RCConversationType to NSNumber when building the array. |
Returns a list of RCConversation objects with message alerts muted upon success.