Skip to main content

Set Do Not Disturb by Conversation

Set Message Do Not Disturb Status for a Conversation

Method

IM service users can set the Do Not Disturb level for a specified conversation or ultra group, supporting one-to-one chat, group chat, and ultra group conversations.

Future<int> changeConversationNotificationLevel(RCIMIWConversationType type, String targetId, String? channelId, RCIMIWPushNotificationLevel level, {IRCIMIWChangeConversationNotificationLevelCallback? callback});

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type. Note the following restrictions:
  • Ultra Group Conversation Type: If the ultra group service was activated before 2022.09.01, it does not support setting the Do Not Disturb level for all messages in a single ultra group conversation ("all messages" refers to messages in all channels and messages not belonging to any channel). This interface only sets the Do Not Disturb status level for messages not belonging to any channel in the specified ultra group conversation (targetId). Submit a ticket if modifications are needed.
  • Chatroom Conversation Type: Not supported, as chatroom messages do not support push notifications by default.
targetIdStringConversation ID/Ultra Group ID
channelIdStringChannel ID for the ultra group conversation. Pass null for other types.
  • If a channel ID is passed, the Do Not Disturb level is set for that specific channel. If no channel ID is specified, it applies to all ultra group messages.
  • Note: For customers who activated the ultra group service before 2022.09.01, if no channel ID is specified, pass an empty string "", meaning the Do Not Disturb status level is set only for messages not belonging to any channel in the specified ultra group conversation (targetId). Submit a ticket if modifications are needed.
levelRCIMIWPushNotificationLevelDo Not Disturb level, refer to Do Not Disturb Overview
callbackIRCIMIWChangeConversationNotificationLevelCallbackEvent callback. The SDK supports callback from version 5.3.1. If the callback parameter is passed, only the callback is triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. Specific results require implementing the interface callback. Non-zero indicates the current operation failed, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWChangeConversationNotificationLevelCallback? callback = IRCIMIWChangeConversationNotificationLevelCallback(onConversationNotificationLevelChanged: (int? code) {
//...
});

int? ret = await engine?.changeConversationNotificationLevel(type, targetId, channelId, level, callback:callback);

Callback Method

  • onConversationNotificationLevelChanged
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, RCIMIWPushNotificationLevel? level)? onConversationNotificationLevelChanged;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
levelRCIMIWPushNotificationLevelMessage notification level

Code Example

engine?.onConversationNotificationLevelChanged = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, RCIMIWPushNotificationLevel? level) {
//...
};

Get Do Not Disturb Status for a Conversation

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

Method

Future<int> getConversationNotificationLevel(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWGetConversationNotificationLevelCallback? callback});

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type. Note the following restrictions:
  • Ultra Group Conversation Type: If the ultra group service was activated before 2022.09.01, it does not support setting the Do Not Disturb level for all messages in a single ultra group conversation ("all messages" refers to messages in all channels and messages not belonging to any channel). This interface only sets the Do Not Disturb status level for messages not belonging to any channel in the specified ultra group conversation (targetId). Submit a ticket if modifications are needed.
  • Chatroom Conversation Type: Not supported, as chatroom messages do not support push notifications by default.
targetIdStringConversation ID/Ultra Group ID
channelIdStringChannel ID for the ultra group conversation. Pass null for other types.
  • If a channel ID is passed, the Do Not Disturb level is set for that specific channel. If no channel ID is specified, it applies to all ultra group messages.
  • Note: For customers who activated the ultra group service before 2022.09.01, if no channel ID is specified, pass an empty string "", meaning the Do Not Disturb status level is set only for messages not belonging to any channel in the specified ultra group conversation (targetId). Submit a ticket if modifications are needed.
callbackIRCIMIWGetConversationNotificationLevelCallbackEvent callback. The SDK supports callback from version 5.3.1. If the callback parameter is passed, only the callback is triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. Specific results require implementing the interface callback. Non-zero indicates the current operation failed, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWGetConversationNotificationLevelCallback? callback = IRCIMIWGetConversationNotificationLevelCallback(onSuccess: (RCIMIWPushNotificationLevel? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getConversationNotificationLevel(type, targetId, channelId, callback:callback);

Callback Method

  • onConversationNotificationLevelLoaded
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, RCIMIWPushNotificationLevel? level)? onConversationNotificationLevelLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
levelRCIMIWPushNotificationLevelCurrent conversation's message notification level

Code Example

engine?.onConversationNotificationLevelLoaded = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, RCIMIWPushNotificationLevel? level) {
//...
};

Get Do Not Disturb Status List

Get the list of all conversations with Do Not Disturb enabled.

Method

Future<int> getBlockedConversations(List<RCIMIWConversationType> conversationTypes, String? channelId, {IRCIMIWGetBlockedConversationsCallback? callback});

Parameter Description

Future<int> getBlockedConversations(List<RCIMIWConversationType> conversationTypes, String? channelId, {IRCIMIWGetBlockedConversationsCallback? callback});

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. Specific results require implementing the interface callback. Non-zero indicates the current operation failed, and the interface callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWGetBlockedConversationsCallback? callback = IRCIMIWGetBlockedConversationsCallback(onSuccess: (List<RCIMIWConversation>? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getBlockedConversations(conversationTypesInt, channelId, callback:callback);

Callback Method

  • onBlockedConversationsLoaded
Function(int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, List<RCIMIWConversation>? conversations)? onBlockedConversationsLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
conversationTypesList<RCIMIWConversationType>Collection of conversation types
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
conversationsList<RCIMIWConversation>Retrieved collection of conversations

Code Example

engine?.onBlockedConversationsLoaded = (int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, List<RCIMIWConversation>? conversations) {
//...
};