会话列表

获取会话列表与单个会话详情;会话按置顶优先、更新时间倒序排列。

平台调用风格

进程模型:main(客户端 + 本地库,单写者)/ preload(contextBridge 具名方法)/ renderer(薄代理)。renderer 不直连网络与数据库。

接口一览​

操作语义传输返回
getConversationList会话列表:置顶优先、按 updatedAt 倒序;含未读/提及/草稿/免打扰。REST(客户端)Conversation[]
getConversation单会话详情。REST(客户端)Conversation

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

跨端方法名​

操作AndroidWebElectronmacOSFlutterNative (C ABI)iOS
getConversationListgetConversationListgetConversationListgetConversationListgetConversationListgetConversationListim_client_conversation_listfunc
getConversationgetConversationgetConversationgetConversationgetConversationgetConversation—func

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

getConversationList​

会话列表:置顶优先、按 updatedAt 倒序;含未读/提及/草稿/免打扰。

getConversationList(options?: {limit?: number; beforeTime?: number; topPriority?: boolean}): Promise<RcResult<Conversation[]>>
REST(客户端)since 1.0.0
返回

Conversation[] 会话列表(置顶优先、updatedAt 倒序;含未读/提及/草稿/免打扰)

示例
JavaScript
const res = await client.getConversationList();
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;

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

getConversation​

单会话详情。

getConversation(conversationType: ConversationType, targetId: string): Promise<RcResult<Conversation>>
REST(客户端)since 1.0.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
targetIdstring必填;目标会话 ID:单聊为对方 userId,群聊为 groupId,聊天室为 chatroomId
返回

Conversation 会话实体(未读数、置顶、草稿、免打扰)

示例
JavaScript
const res = await client.getConversation(ConversationType.PRIVATE, 'user2');
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

相关文档​