V2TimConversation information of each conversation and add the unreadCount values of all the V2TimConversation objects to get the final result and display it on the UI.getTotalUnreadMessageCount API to query the total unread count of all the conversations.
When the total unread count changes, the SDK will notify you of the latest total unread count through the onTotalUnreadMessageCountChanged callback.getTotalUnreadMessageCount (Details) to get the total unread count of all the conversations and update it on the UI.// Get the total unread countV2TimValueCallback<int> unread = await conversationManager.getTotalUnreadMessageCount();
addConversationListener (Details) to add a conversation listener to receive notifications of a change in the total unread count.onTotalUnreadMessageCountChanged (Details) of V2TIMConversationListener.conversationManager.addConversationListener(listener: V2TimConversationListener(onTotalUnreadMessageCountChanged: (totalUnreadCount) {// Latest unread count},));
Parameter | Meaning | Valid in One-on-One Chat | Valid in Group Chat | Remarks |
conversationID | Unique conversation ID | YES | YES | The composition method of a C2C (one-on-one) chat is: "c2c_userID"; the composition method of a group chat is: "group_groupID". |
cleanTimestamp | Clear timestamp | YES | NO | Specify the timestamp before which the unread message count will be cleared. When 0 is passed in, all unread messages in the corresponding conversation will be cleared, and the unread count of the conversation will be set to 0. |
cleanSequence | Clear sequence | NO | YES | Specify the sequence before which the unread message count will be cleared. When 0 is passed in, all unread messages in the corresponding conversation will be cleared, and the unread count of the conversation will be set to 0. |
TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(conversationID: "c2c_userID",cleanTimestamp: 0,cleanSequence: 0,);
cleanConversationUnreadMessageCount is called successfully:addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.onRecvC2CReadReceipt callback that contains the timestamp when the conversation unread count is cleared.// ReceiverconversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {// Latest conversation after the change},));// SenderTencentImSDKPlugin.v2TIMManager.getMessageManager().addAdvancedMsgListener(listener: V2TimAdvancedMsgListener(onRecvC2CReadReceipt: (receiptList) {// The message is read by the receiver.},));
TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(conversationID: "c2c",cleanTimestamp: 0,cleanSequence: 0,);
cleanConversationUnreadMessageCount is called successfully, if the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {// Latest conversation after the change},));
TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(conversationID: "group_groupID",cleanTimestamp: 0,cleanSequence: 0,);
cleanConversationUnreadMessageCount is called successfully, if the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {// Latest conversation after the change},));
TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(conversationID: "group",cleanTimestamp: 0,cleanSequence: 0,);
cleanConversationUnreadMessageCount is called successfully, if the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {// Latest conversation after the change},));
TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(conversationID: "",cleanTimestamp: 0,cleanSequence: 0,);
cleanConversationUnreadMessageCount is called successfully, if the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {// Latest conversation after the change},));
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback