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 Pin Status​

Method​

Future<int> changeConversationTopStatus(RCIMIWConversationType type, String targetId, String? channelId, bool top, {IRCIMIWChangeConversationTopStatusCallback? callback});

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
topboolWhether to pin
callbackIRCIMIWChangeConversationTopStatusCallbackEvent callback. The SDK supports callback mode starting from version 5.3.1. Other callback modes for this interface are deprecated starting from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>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. For detailed errors, refer to the error codes.

Code Example​

IRCIMIWChangeConversationTopStatusCallback? callback = IRCIMIWChangeConversationTopStatusCallback(onConversationTopStatusChanged: (int? code) {
//...
});

int? ret = await engine?.changeConversationTopStatus(type, targetId, channelId, top, callback:callback);

Callback Method​

  • onConversationTopStatusChanged
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, bool? top)? onConversationTopStatusChanged;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
topboolWhether to pin

Code Example

engine?.onConversationTopStatusChanged = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, bool? top) {
//...
};

Get Conversation Pin Status​

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

Method​

Future<int> getConversationTopStatus(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWGetConversationTopStatusCallback? callback});

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetConversationTopStatusCallbackEvent callback. The SDK supports callback mode starting from version 5.3.1. Other callback modes for this interface are deprecated starting from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>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. For detailed errors, refer to the error codes.

Code Example​

IRCIMIWGetConversationTopStatusCallback? callback = IRCIMIWGetConversationTopStatusCallback(onSuccess: (bool? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getConversationTopStatus(type, targetId, channelId, callback:callback);

Callback Method​

  • onConversationTopStatusLoaded
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, bool? top)? onConversationTopStatusLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
topboolWhether to pin

Code Example

engine?.onConversationTopStatusLoaded = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, bool? top) {
//...
};

Get Pinned Conversation List​

Get the list of pinned conversations.

Method​

Future<int> getTopConversations(List<RCIMIWConversationType> conversationTypes, String? channelId, {IRCIMIWGetTopConversationsCallback? callback});

Parameter Description​

ParameterTypeDescription
conversationTypesList<RCIMIWConversationType>Collection of conversation types
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetTopConversationsCallbackEvent callback. The SDK supports callback mode starting from version 5.3.1. Other callback modes for this interface are deprecated starting from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>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. For detailed errors, refer to the error codes.

Code Example​

IRCIMIWGetTopConversationsCallback? callback = IRCIMIWGetTopConversationsCallback(onSuccess: (List<RCIMIWConversation>? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getTopConversations(conversationTypesInt, channelId, callback:callback);

Callback Method​

  • onTopConversationsLoaded
Function(int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, List<RCIMIWConversation>? conversations)? onTopConversationsLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, non-zero indicates an exception.
conversationTypesList<RCIMIWConversationType>Collection of conversation types
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
conversationsList<RCIMIWConversation>Loaded collection of conversations

Code Example

engine?.onTopConversationsLoaded = (int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, List<RCIMIWConversation>? conversations) {
//...
};

Pin Status Synchronization​

The SDK provides a conversation status (pinned or do not disturb) synchronization mechanism. By setting a conversation status synchronization listener, when the conversation status is modified on another device, the change in conversation status can be monitored in real-time on this device.

Method​

Function(RCIMIWConversationType? type, String? targetId, String? channelId, bool? top)? onConversationTopStatusSynced;

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types. Channel ID, only supported for ultra groups. Pass null for other conversation types.
topboolWhether to pin

Code Example​

engine?.onConversationTopStatusSynced = (RCIMIWConversationType? type, String? targetId, String? channelId, bool? top) {
//...
};