跳到主要内容

会话顶置

SDK 提供设置会话是否置顶接口,置顶的状态将会被同步到服务端,切换设备后置顶状态也会一并同步下来。

设置会话置顶

方法

TypeScript

changeConversationTopStatus(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
top: boolean,
callback: IRCIMIWChangeConversationTopStatusCallback
): Promise<number>;

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型
targetIdstring会话 ID
channelIdstring频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
topboolean是否置顶
callbackIRCIMIWChangeConversationTopStatusCallback接口调用结果回调。

返回值

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

代码示例

TypeScript

const callback = {
onConversationTopStatusChanged: (code: number) => {
//...
},
};
let code = await engine.changeConversationTopStatus(type, targetId, channelId, top, callback);

获取会话置顶状态

通过此方法获取指定会话的置顶状态。

方法

TypeScript

getConversationTopStatus(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWGetConversationTopStatusCallback
): Promise<number>;

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型
targetIdstring会话 ID
channelIdstring频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
callbackIRCIMIWGetConversationTopStatusCallback接口调用结果回调。

返回值

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

代码示例

TypeScript

const callback = {
onSuccess: (t: Boolean) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getConversationTopStatus(type, targetId, channelId, callback);

获取置顶会话列表

获取置顶会话列表

方法

TypeScript

getTopConversations(
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
callback: IRCIMIWGetTopConversationsCallback
): Promise<number>;

参数说明

参数名参数类型描述
conversationTypesArray<RCIMIWConversationType>会话类型集合
channelIdstring频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
callbackIRCIMIWGetTopConversationsCallback接口调用结果回调。

返回值

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

代码示例

TypeScript

const callback = {
onSuccess: (t: Array<RCIMIWConversation>) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getTopConversations(conversationTypes, channelId, callback);

置顶状态同步

SDK 提供了会话状态(置顶或免打扰)同步机制,通过设置会话状态同步监听器,当在其它端修改会话状态时,可在本端实时监听到会话状态的改变。

方法

TypeScript
setOnConversationTopStatusSyncedListener(listener?: (type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => void): void;

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型
targetIdstring会话 ID
channelIdstring频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
topboolean是否置顶

代码示例

TypeScript

engine?.setOnConversationTopStatusSyncedListener(
(type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => {
//...
},
);