会话删除与类型免打扰

删除会话记录(只删会话行,不删历史消息)与按会话类型设置提醒级别;类型级设置优先于全局默认,单会话设置优先于类型级设置。

平台调用风格

异步风格:Future<RcResult<T>>;错误码在 res.code,不使用异常表达业务失败。

接口一览​

操作语义传输返回
deleteConversation删除会话记录(列表项/未读/草稿/置顶),历史消息保留;同时从标签移除;幂等。REST(客户端){removed:bool}
getConversationTypeNotification查询按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。REST(客户端){conversationType:int, level:int}
setConversationTypeNotification设置按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。REST(客户端){conversationType:int, level:int}

本页 3 个操作,其中 3 个在本平台绑定中声明了方法签名。

跨端方法名​

操作AndroidWebElectronmacOSFlutterNative (C ABI)iOS
deleteConversationdeleteConversationdeleteConversationdeleteConversationdeleteConversationdeleteConversation—func
getConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotification—func
setConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotification—func

方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。

deleteConversation​

删除会话记录(列表项/未读/草稿/置顶),历史消息保留;同时从标签移除;幂等。

deleteConversation(int conversationType, String targetId)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
targetIdstring必填;目标会话 ID:单聊为对方 userId,群聊为 groupId,聊天室为 chatroomId
返回

{removed:bool} 成功返回的数据;失败时按错误码处理

示例
Dart
final res = await engine.deleteConversation(1, 'user2');
if (res.code != 0) throw Exception(res.msg);

该操作未声明专属错误码;失败时按 SDK 通用错误处理,见 状态码。

getConversationTypeNotification​

查询按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

getConversationTypeNotification(int conversationType)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
返回

{conversationType:int, level:int} 成功返回的数据;失败时按错误码处理

示例
Dart
final res = await engine.getConversationTypeNotification(1);
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

setConversationTypeNotification​

设置按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

setConversationTypeNotification(int conversationType, int level)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
levelint必填;字段含义见类型定义
返回

{conversationType:int, level:int} 成功返回的数据;失败时按错误码处理

示例
Dart
final res = await engine.setConversationTypeNotification(1, 0);
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

相关文档​