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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
top | boolean | Whether to pin |
callback | IRCIMIWChangeConversationTopStatusCallback | Callback for the interface call result. |
Return Value
Return Value | Description |
---|---|
number | The 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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
callback | IRCIMIWGetConversationTopStatusCallback | Callback for the interface call result. |
Return Value
Return Value | Description |
---|---|
number | The 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 Name | Parameter Type | Description |
---|---|---|
conversationTypes | Array<RCIMIWConversationType> | Collection of conversation types |
channelId | string | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
callback | IRCIMIWGetTopConversationsCallback | Callback for the interface call result. |
Return Value
Return Value | Description |
---|---|
number | The 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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
top | boolean | Whether to pin |
Code Example
engine?.setOnConversationTopStatusSyncedListener(
(type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => {
//...
}
);