Conversation Mark
Overview
In some cases, you may need to mark a conversation, for example, as "favorite", "collapsed", "hidden", or "unread", which can be implemented through the following API.
Note:
To use this feature, you need to purchase the Ultimate edition.
This feature is supported only on native SDK 6.5 or later.
Conversation Mark
Marking a conversation
Caution:
When a user marks a conversation, the SDK records only the mark value and will not change the underlying logic of the conversation. For example, if a conversation is marked as
kTIMConversationMarkTypeUnread
, the unread count at the underlying layer will not change.Parameters of the API for marking a conversation are as described below:
Attribute | Definition | Description |
conversationIDList | List of conversation IDs | Up to 100 conversations can be marked at a time. |
markType | Mark type | A conversation can be marked as a favorite, unread, collapsed, or hidden. |
enableMark | Mark/Unmark | A conversation can be marked/unmarked. |
Note:
The SDK provides four default marks ("favorite", "collapsed", "hidden", and "unread"). If they cannot meet your requirements, you can customize extended marks, which must meet the following conditions:
The value of an extended mark cannot be the same as that of an existing one.
The value of an extended mark must be 0x1LL << displacement value of n (
32 ≤ n < 64
indicates that n
must be equal to or greater than 32 and less than 64). For example, 0x1LL << 32
indicates "Online on an iPhone".Sample code:
// Mark a conversationTIMResult res = TencentIMSDK.ConvMarkConversation(new List<string> {conv_id}, TIMConversationMarkType.kTIMConversationMarkTypeStar, true, (int code, string desc, List<ConversationOperationResult> results, string user_data)=>{// Async result of the conversation marking});
Listening for the notification of a conversation mark change
After a conversation is marked or unmarked, the
conv_mark_array
(details) field of the conversation's ConvInfo
will be changed. You can call the SetConvEventCallback
(details) API to listen for conversation change notifications.Sample code:
// Set the conversation listenerTencentIMSDK.SetConvEventCallback((TIMConvEvent conv_event, List<ConvInfo> conv_list, string user_data)=>{// Process the callback logic});
Pulling a specified marked conversation
Sample code:
// Get the conversation listConversationListFilter filter = new ConversationListFilter{conversation_list_filter_conv_type: TIMConvType.kTIMConv_C2C,// Conversation typeconversation_list_filter_mark_type: TIMConversationMarkType.kTIMConversationMarkTypeStar,// Conversation mark typeconversation_list_filter_conversation_group: "groupName"// Named of the group whose data is to be pulled};ulong next_seq = 0; // Pulling cursoruint count = 10; // Pulling count// Advanced API for getting the conversation listTIMResult res = TencentIMSDK.ConvGetConversationListByFilter(filter, next_seq, count, (int code, string desc, ConversationListResult result, string user_data)=>{// Async result of the conversation list gettingif (code == 0) {// Pulled successfullybool isFinished = result.conversation_list_result_is_finished; // Whether pulling is completednext_seq = result.conversation_list_result_next_seq; // Cursor for subsequent paged pullingvar conversationList = result.conversation_list_result_conv_list; // List of messages pulled this time// If more conversations need to be pulled, use the returned `nextSeq` to continue pulling until `isFinished` is `true`.}});