Skip to main content

Pin Conversations

The SDK provides an interface to set whether a conversation is pinned. The pinned status will be synchronized to the server, and the pinned status will also be synchronized when switching devices.

Set Conversation as Pinned

Method


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

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
topbooleanWhether to pin
callbackIRCIMIWChangeConversationTopStatusCallbackCallback for the interface call result.

Return Value

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates a successful call. The specific result needs to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. Refer to the error codes for detailed errors.

Code Example


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

Get Conversation Pinned Status

Use this method to get the pinned status of a specified conversation.

Method


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

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWGetConversationTopStatusCallbackCallback for the interface call result.

Return Value

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates a successful call. The specific result needs to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. Refer to the error codes for detailed errors.

Code Example


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

Get Pinned Conversations List

Get the list of pinned conversations.

Method


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

Parameter Description

Parameter NameParameter TypeDescription
conversationTypesArray<RCIMIWConversationType>Collection of conversation types
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWGetTopConversationsCallbackCallback for the interface call result.

Return Value

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates a successful call. The specific result needs to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. Refer to the error codes for detailed errors.

Code Example


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

Pinned Status Synchronization

The SDK provides a conversation status (pinned or Do Not Disturb) synchronization mechanism. By setting a conversation status synchronization listener, you can listen to changes in conversation status in real-time on this end when the status is modified on other ends.

Method

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

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
topbooleanWhether to pin

Code Example


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