会话删除与类型免打扰

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

平台调用风格

回调式(callback-last):有返回数据用 ResultCallback<T>,无返回数据用 OperationCallback;所有回调在主线程投递。

接口一览​

操作语义传输返回
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(conversationType: Int, targetId: String, callback: ResultCallback<Boolean>?)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
targetIdstring必填;目标会话 ID:单聊为对方 userId,群聊为 groupId,聊天室为 chatroomId
返回

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

示例
Kotlin
client.deleteConversation(
    conversationType = ConversationType.PRIVATE,
    targetId = "user2",
    callback = object : ResultCallback<Boolean> {
        override fun onSuccess(result: Boolean) { /* 处理返回数据 */ }
        override fun onError(error: IMError) { /* 处理 error.code */ }
    },
)

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

getConversationTypeNotification​

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

getConversationTypeNotification(conversationType: Int, callback: ResultCallback<ConversationTypeNotification>?)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
返回

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

示例
Kotlin
client.getConversationTypeNotification(
    conversationType = ConversationType.PRIVATE,
    callback = object : ResultCallback<ConversationTypeNotification> {
        override fun onSuccess(result: ConversationTypeNotification) { /* 处理返回数据 */ }
        override fun onError(error: IMError) { /* 处理 error.code */ }
    },
)
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

setConversationTypeNotification​

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

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

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

示例
Kotlin
client.setConversationTypeNotification(
    conversationType = ConversationType.PRIVATE,
    level = NotificationLevel.ALL,
    callback = object : ResultCallback<ConversationTypeNotification> {
        override fun onSuccess(result: ConversationTypeNotification) { /* 处理返回数据 */ }
        override fun onError(error: IMError) { /* 处理 error.code */ }
    },
)
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

相关文档​