• UIKit
  • SDK
  • 서버 API
Chat/
SDK/
Flutter/
대화/
SDK
  • Chat SDK 설치
    • 설치
  • Chat SDK 초기화
    • 초기화
  • 로그인 및 로그아웃
    • 로그인 및 로그아웃
  • 메시지
    • 메시지 개요
    • 메시지 보내기
    • 메시지 받기
    • 과거 메시지
    • 메시지 전달
    • 메시지 수정
    • 메시지 삽입
    • 메시지 삭제
    • 메시지 비우기
    • 메시지 철회
    • 온라인 메시지
    • 읽음 확인
    • 메시지 조회
    • 그룹 @ 메시지
    • 지향적 그룹 메시지
    • 알림 음소거
    • 메시지 확장
  • 대화
    • 대화 개요
    • 대화 목록
    • 대화 획득
    • 읽지 않은 대화 수
    • 대화 최상단 고정
    • 대화 삭제
    • 대화 초안
    • 대화 그룹
  • 그룹
    • 그룹 개요
    • 그룹 관리
    • 그룹 정보
    • 그룹 멤버 관리
    • 그룹 멤버 정보
    • 그룹 속성 사용자 정의
  • 사용자
    • 사용자 정보
    • 친구 관리
    • 친구 목록
    • 블록리스트
  • 오프라인 푸시
    • 오프라인 푸시
  • 시그널링
    • 시그널링 관리
  • 국부 검색
    • 메시지 검색
    • 친구 검색
    • 그룹 검색
    • 그룹 멤버 검색
  • 인터페이스 참고 문서
    • 고객 인터페이스
  • Guideline for Beginners
  • 콘솔 안내
    • 애플리케이션 생성 및 업그레이드
    • 기본 구성
    • 기능 구성
    • 계정 관리
    • 그룹 관리
    • 콜백 구성
  • 제품 소개
    • 메시지 관리
      • 1대1 메시지
      • 메시지 저장
      • 오프라인 푸시
      • 그룹 메시지
      • 메시지 포맷
    • 계정 시스템
      • 로그인 인증
      • 온라인 상태 관리
    • 그룹 관련
      • 그룹 시스템
      • 그룹 관리
    • 사용자 정보 및 관계망
      • 정보 관리
      • 관계망 관리
  • 구매 가이드
    • 과금 개요
    • 가격
  • 에러코드
이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

읽지 않은 대화 수

Feature Description

A user's conversation list usually contains multiple conversations. If there is a new message in one of the conversations, a badge needs to be displayed in the list cell to indicate the unread count. After the user clicks to enter the conversation and goes back to the conversation list, the unread count is cleared, and the badge disappears. In some applications, the total unread count of all the conversations is calculated and displayed at the bottom tab of the conversation list.
This document describes how to implement the conversation unread count notification feature.

Getting the Total Unread Count of All the Conversations

In general cases, to get the total unread count of all the conversations, you can traverse the conversation list to get the 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. The IM SDK provides the 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.
Note:
This feature is supported only by the SDK for Flutter on v3.0.0 or later.
Below are detailed steps.

Getting the total unread count

Call getTotalUnreadMessageCount (Details) to get the total unread count of all the conversations and update it on the UI.
Sample code:
// Get the total unread count
V2TimValueCallback<int> unread = await conversationManager.getTotalUnreadMessageCount();

Notification of a change in the total unread count

Call addConversationListener (Details) to add a conversation listener to receive notifications of a change in the total unread count.
You can get the changed total unread count in onTotalUnreadMessageCountChanged (Details) of V2TIMConversationListener.
Sample code:
conversationManager.addConversationListener(listener: V2TimConversationListener(onTotalUnreadMessageCountChanged: (totalUnreadCount) {
// Latest unread count
},));

Clearing the Conversation Unread Count

After the user clicks to enter a conversation and goes back to the conversation list, the unread count needs to be cleared, after which the badge in the conversation list needs to disappear. The IM SDK provides three APIs to clear the unread count for different conversation types:
markC2CMessageAsRead is used to clear the unread count of a one-to-one conversation.
markGroupMessageAsRead is used to clear the unread count of a group conversation.
markAllMessageAsRead is used to clear the unread count of all the conversations.
Below are detailed steps.
Note:
This feature is supported only by the SDK of the Enhanced edition on v5.8.1668 or later.

One-to-one chat

Call markC2CMessageAsRead (Details) to clear the unread count of a specified one-to-one conversation.
Sample code:
TencentImSDKPlugin.v2TIMManager.getMessageManager().markC2CMessageAsRead(userID: "userID");
After markC2CMessageAsRead is called successfully:
1. If the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.
2. The sender will receive the onRecvC2CReadReceipt callback that contains the timestamp when the conversation unread count is cleared.
Sample code:
// Receiver
conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {
// Latest conversation after the change
},));

// Sender
TencentImSDKPlugin.v2TIMManager.getMessageManager().addAdvancedMsgListener(listener: V2TimAdvancedMsgListener(onRecvC2CReadReceipt: (receiptList) {
// The message is read by the receiver.
},));

Group chat

Call markGroupMessageAsRead (Details) to clear the unread count of a specified group conversation.
Sample code:
TencentImSDKPlugin.v2TIMManager.getMessageManager().markGroupMessageAsRead(groupID: "groupID");
After markGroupMessageAsRead is called successfully, if the caller has called addConversationListener to add a conversation listener, it will receive the onConversationChanged callback and update the UI.
Sample code:
conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {
// Latest conversation after the change
},));

All conversations

Call markAllMessageAsRead (Details) to clear the unread count of all the conversations.
Sample code:
TencentImSDKPlugin.v2TIMManager.getMessageManager().markAllMessageAsRead();
After markAllMessageAsRead is called successfully, if the caller has called addConversationListener in advance to add a conversation listener, it will receive the onConversationChanged callback and update the UI.
Sample code:
conversationManager.addConversationListener(listener: V2TimConversationListener(,onConversationChanged: (conversationList) {
// Latest conversation after the change
},));