跳到主要内容

按会话设置免打扰

设置会话的消息免打扰状态

方法

即时通讯业务用户为指定会话或超级群设置免打扰级别,支持单聊、群聊、超级群会话。

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

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型。请注意以下限制:
  • 超级群会话类型:如在 2022.09.01 之前开通超级群业务,默认不支持为单个超级群会话所有消息设置免打扰级别(“所有消息”指所有频道中的消息和不属于任何频道的消息)。该接口仅设置指定超级群会话(targetId)中不属于任何频道的消息的免打扰状态级别。如需修改请提交工单。
  • 聊天室会话类型:不支持,因为聊天室消息默认不支持消息推送提醒。
targetIdString会话 ID/超级群ID
channelIdString超级群的会话频道 ID。其他类型传 null 即可。
  • 如果传入频道 ID,则针对该指定频道设置消息免打扰级别。如果不指定频道 ID,则对所有超级群消息生效。
  • 注意:2022.09.01 之前开通超级群业务的客户,如果不指定频道 ID,则默认传 "" 空字符串,即仅针对指定超级群会话(targetId)中不属于任何频道的消息设置免打扰状态级别。如需修改请提交工单。
levelRCIMIWPushNotificationLevel免打扰级别,参考免打扰概述
callbackIRCIMIWChangeConversationNotificationLevelCallback事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。如果传入了 callback 参数,仅触发 callback 回调。

返回值

返回值描述
Future<int>当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码

代码示例

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

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

回调方法

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

参数说明

参数名参数类型描述
codeint接口回调的状态码,0 代表成功,非 0 代表出现异常
typeRCIMIWConversationType会话类型
targetIdString会话 ID
channelIdString频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
levelRCIMIWPushNotificationLevel消息通知级别

代码示例

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

获取会话的免打扰状态

查询当前用户为指定会话设置的免打扰级别

方法

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

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型。请注意以下限制:
  • 超级群会话类型:如在 2022.09.01 之前开通超级群业务,默认不支持为单个超级群会话所有消息设置免打扰级别(“所有消息”指所有频道中的消息和不属于任何频道的消息)。该接口仅设置指定超级群会话(targetId)中不属于任何频道的消息的免打扰状态级别。如需修改请提交工单。
  • 聊天室会话类型:不支持,因为聊天室消息默认不支持消息推送提醒。
targetIdString会话 ID/超级群ID
channelIdString超级群的会话频道 ID。其他类型传 null 即可。
  • 如果传入频道 ID,则针对该指定频道设置消息免打扰级别。如果不指定频道 ID,则对所有超级群消息生效。
  • 注意:2022.09.01 之前开通超级群业务的客户,如果不指定频道 ID,则默认传 "" 空字符串,即仅针对指定超级群会话(targetId)中不属于任何频道的消息设置免打扰状态级别。如需修改请提交工单。
callbackIRCIMIWGetConversationNotificationLevelCallback事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。如果传入了 callback 参数,仅触发 callback 回调。

返回值

返回值描述
Future<int>当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码

代码示例

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

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

回调方法

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

参数说明

参数名参数类型描述
codeint接口回调的状态码,0 代表成功,非 0 代表出现异常
typeRCIMIWConversationType会话类型
targetIdString会话 ID
channelIdString频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
levelRCIMIWPushNotificationLevel当前会话的消息通知级别

代码示例

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

获取免打扰状态列表

获取所有设置了消息免打扰的会话列表。

方法

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

参数说明

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

返回值

返回值描述
Future<int>当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码

代码示例

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

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

回调方法

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

参数说明

参数名参数类型描述
codeint接口回调的状态码,0 代表成功,非 0 代表出现异常
conversationTypesList<RCIMIWConversationType>会话类型集合
channelIdString频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
conversationsList<RCIMIWConversation>获取到的会话集合

代码示例

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