Pin a conversation
Introduction
Pinning conversations refers to fixing one-on-one or group chat conversations at the top of the conversation list, preventing them from being pushed to the bottom by other non-pinned conversations, and making it easier for users to find them. When users pin a conversation through the client, the pinned status is stored on the server. Therefore, when users switch to another device, the pinned status will be synchronized to the current device.
ZIM supports users to pin conversations and query the pinned conversation list
- Pinned conversations are only supported in ZIM SDK version 2.8.0 or above.
- The maximum limit for pinned conversations is 100.
-
Pinned conversations are always placed before unpinned conversations.
NoteThis rule also applies to the conversation list fetched by calling the queryConversationList interface. Developers can confirm whether a conversation is pinned by checking the isPinned field of the ZIMConversation in the fetched results.
-
After a user pins multiple conversations, the relative order between these conversations will remain unchanged.
Let's assume there are 5 conversations, and the existing order in the conversation list is: a, b, c, d, e.
If the user pins conversations b and d (regardless of the order in which they are pinned), the new order will be b, d, a, c, e. In other words, conversations b and d are placed at the front, and conversation b is still placed before conversation d.NoteThe above example assumes that the orderKey of the related conversations remains unchanged before and after pinning. If the orderKey changes, the order in the pinned conversation list will also change.
Pin a conversation
After the login, a user can pin or unpin a conversation in their conversation list by calling the updateConversationPinnedState interface.
// Pin a one-on-one conversation
ZIM.GetInstance().UpdateConversationPinnedState(
true, "conv_id", ZIMConversationType.Peer,
(string conversationID, ZIMConversationType conversationType,
ZIMError errorInfo) {
// Callback notification for the result of the pinned conversation operation
if (errorInfo.code == ZIMErrorCode.Success) {
//......
} else {
// You can print the error code and error message to troubleshoot the issue, refer to the ZIM official website error code documentation for troubleshooting
}
});
Get the pinned conversation list
After the login, a user can use the queryConversationPinnedList interface to get the full list of pinned conversations.
ZIMConversationQueryConfig config = new ZIMConversationQueryConfig();
// Conversation anchor, pass empty to query from the latest
config.nextConversation = null;
// Number of top conversations to retrieve each time
config.count = 100;
// Fetching the list of pinned conversations
ZIM.GetInstance().QueryConversationPinnedList(
config,
[=](List<ZIMConversation> convList, ZIMError errorInfo) {
// Callback notification for fetching the results of the operation to retrieve the list of pinned conversations.
if (errorInfo.code == ZIMErrorCode.Success) {
foreach (var conv in convList) {
//......
}
} else {
// You can print the error code and error message to troubleshoot the error cause. Please refer to the ZIM official website error code documentation for further investigation.
}
});