会话顶置
SDK 提供设置会话是否置顶接口,置顶的状态将会被同步到服务端,切换设备后置顶状态也会一并同步下来。
设置会话置顶
方法
changeConversationTopStatus(type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean): Promise<number>;
参数说明
参数 | 类型 | 说明 |
---|---|---|
type | RCIMIWConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,暂不支持该参数。传 null 即可。 |
top | boolean | 是否置顶,true置顶,false,不置顶 |
代码示例
engine.changeConversationTopStatus(
type,
targetId,
channelId,
top
)
.then((code: number) => {});
返回值
返回值 | 描述 |
---|---|
Promise<number> | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- setOnConversationTopStatusChangedListener
setOnConversationTopStatusChangedListener(listener?: (code: number, type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => void): void;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | number | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
type | RCIMIWConversationType | 调用接口时传入的会话类型 |
targetId | string | 调用接口时传入的会话 ID |
channelId | string | 调用接口时传入的频道 ID |
top | boolean | 置顶状态 |
代码示例
engine.setOnConversationTopStatusChangedListener(
(
code: number,
type: RCIMIWConversationType,
targetId: string,
channelId: string,
top: boolean
) => {}
);
获取会话置顶状态
通过此方法获取指定会话的置顶状态。
方法
loadConversationTopStatus(type: RCIMIWConversationType, targetId: string, channelId: string): Promise<number>;
参数说明
参数 | 类型 | 说明 |
---|---|---|
type | RCIMIWConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,暂不支持该参数。传 null 即可。 |
代码示例
engine.loadConversationTopStatus(
type,
targetId,
channelId
)
.then((code: number) => {});
返回值
返回值 | 描述 |
---|---|
Promise<number> | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- setOnConversationTopStatusLoadedListener
setOnConversationTopStatusLoadedListener(listener?: (code: number, type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => void): void;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | number | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
type | RCIMIWConversationType | 调用接口时传入的会话类型 |
targetId | string | 调用接口时传入的会话 ID |
channelId | string | 调用接口时传入的频道 ID |
top | boolean | 置顶状态 |
代码示例
engine.setOnConversationTopStatusLoadedListener(
(
code: number,
type: RCIMIWConversationType,
targetId: string,
channelId: string,
top: boolean
) => {}
);
获取置顶会话列表
获取置顶会话列表
方法
loadTopConversations(conversationTypes: Array<RCIMIWConversationType>, channelId: string): Promise<number>;
参数说明
参数 | 类型 | 说明 |
---|---|---|
conversationType | RCIMIWConversationType | 会话类型 |
channelId | string | 频道 ID,暂不支持该参数。传 null 即可。 |
代码示例
engine.loadTopConversations(
conversationTypes,
channelId
)
.then((code: number) => {});
返回值
返回值 | 描述 |
---|---|
Promise<number> | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- setOnTopConversationsLoadedListener
setOnTopConversationsLoadedListener(listener?: (code: number, conversationTypes: Array<RCIMIWConversationType>, channelId: string, conversations: Array<RCIMIWConversation>) => void): void;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | number | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
conversationTypes | Array<[RCIMIWConversationType](https://www.rongcloud.cn/docs/api/react-native/imlib_v5/latest/enums/RCIMDefines.RCIMIWConversationType.html)> | 调用接口时传入的会话类型列表 |
channelId | string | 调用接口时传入的频道 ID |
conversations | Array<[RCIMIWConversation](https://www.rongcloud.cn/docs/api/react-native/imlib_v5/latest/interfaces/RCIMDefines.RCIMIWConversation.html)> | 置顶的会话列表 |
代码示例
engine.setOnTopConversationsLoadedListener(
(
code: number,
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
conversations: Array<RCIMIWConversation>
) => {}
);
置顶状态同步
SDK 提供了会话状态(置顶或免打扰)同步机制,通过设置会话状态同步监听器,当在其它端修改会话状态时,可在 本端实时监听到会话状态的改变。
方法
setOnConversationTopStatusSyncedListener(listener?: (type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => void): void;
参数说明
参数 | 类型 | 说明 |
---|---|---|
conversationType | RCIMIWConversationType | 会话类型 |
targetId | string | 会话ID |
channelId | string | 频道 ID |
top | boolean | 是否置顶 |
代码示例
engine.setOnConversationTopStatusSyncedListener(
(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
top: boolean
) => {}
);