IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMConversationManagerabstract

Public Member Functions

abstract void setConversationListener (V2TIMConversationListener listener)
 
abstract void addConversationListener (V2TIMConversationListener listener)
 
abstract void removeConversationListener (V2TIMConversationListener listener)
 
abstract void getConversationList (long nextSeq, int count, V2TIMValueCallback< V2TIMConversationResult > callback)
 
abstract void getConversation (String conversationID, V2TIMValueCallback< V2TIMConversation > callback)
 
abstract void getConversationList (List< String > conversationIDList, V2TIMValueCallback< List< V2TIMConversation >> callback)
 
abstract void deleteConversation (String conversationID, V2TIMCallback callback)
 
abstract void setConversationDraft (String conversationID, String draftText, V2TIMCallback callback)
 
abstract void pinConversation (String conversationID, boolean isPinned, V2TIMCallback callback)
 
abstract void getTotalUnreadMessageCount (V2TIMValueCallback< Long > callback)
 

Detailed Description

Conversation APIs, including the APIs for getting, deleting, and updating conversations

Member Function Documentation

◆ setConversationListener()

abstract void setConversationListener ( V2TIMConversationListener  listener)
abstract

1.1 Set the conversation listener

◆ addConversationListener()

abstract void addConversationListener ( V2TIMConversationListener  listener)
abstract

1.2 Add the conversation listener

◆ removeConversationListener()

abstract void removeConversationListener ( V2TIMConversationListener  listener)
abstract

1.3 Remove the conversation listener

◆ getConversationList() [1/2]

abstract void getConversationList ( long  nextSeq,
int  count,
V2TIMValueCallback< V2TIMConversationResult callback 
)
abstract

1.4 Get the conversation list

  • Each conversation corresponds to a chat window. For example, a one-to-one chat or a chat group is a conversation.
  • Since there may be a large number of historical conversations, you are advised to call this API in query-by-page mode and pull 100 historical conversations per page at a time.
  • This API pulls locally cached conversations. If conversations on the server are updated, the SDK automatically synchronizes the updates internally and then notifies users via V2TIMConversationListener callback.
  • If all conversations are pulled, the value of the isFinished field in V2TIMConversationResult in the success callback is true.
Attention
Conversation sorting rules
  • For 5.5.892 and later versions, conversations on the conversion list obtained by this API are sorted by orderKey by default. The larger the orderKey value, the higher the order of the conversation.
  • For versions earlier than 5.5.892, conversations on the conversion list obtained by this API are sorted by "lastMessage -> timestamp" by default. The later the timestamp, the higher the order of the conversation.
Parameters
nextSeqPulling-by-page cursor. It is set to 0 when the information is pulled for the first time. The value of this field in the callback for the current paginated pulling is passed in for the next pull.
countNumber of conversations pulled per page. The value of this field cannot be too large; otherwise, the pulling speed is affected. We recommend that you pull 100 conversations per page.

◆ getConversation()

abstract void getConversation ( String  conversationID,
V2TIMValueCallback< V2TIMConversation callback 
)
abstract

1.5 Get a single conversation

Parameters
conversationIDUnique ID of a conversation. For one-to-one chats, the value format is String.format("c2c_%s", "userID"). For group chats, the value format is String.format("group_%s", "groupID").

◆ getConversationList() [2/2]

abstract void getConversationList ( List< String >  conversationIDList,
V2TIMValueCallback< List< V2TIMConversation >>  callback 
)
abstract

1.6 Get a specified conversation list

Parameters
conversationIDListList of the unique IDs of conversations. For one-to-one chats, the value format is String.format("c2c_%s", "userID"). For group chats, the value format is String.format("group_%s", "groupID").

◆ deleteConversation()

abstract void deleteConversation ( String  conversationID,
V2TIMCallback  callback 
)
abstract

1.7 Delete a conversation

Parameters
conversationIDUnique ID of a conversation. For one-to-one chats, the value format is String.format("c2c_%s", "userID"). For group chats, the value format is String.format("group_%s", "groupID").
Attention
Notes:
  • When a conversation is deleted from local storage, it is also deleted from the server.
  • When messages in a conversation are deleted from local storage, they are also deleted from the server.

◆ setConversationDraft()

abstract void setConversationDraft ( String  conversationID,
String  draftText,
V2TIMCallback  callback 
)
abstract

1.8 Set a draft for a conversation

Parameters
conversationIDUnique ID of a conversation. For one-to-one chats, the value format is String.format("c2c_%s", "userID"). For group chats, the value format is String.format("group_%s", "groupID").

Drafts are stored only locally and are not stored on the server. Therefore, drafts cannot be synchronized across multiple devices. If the app is uninstalled and reinstalled, drafts become invalid.

Parameters
draftTextDraft content. The value null indicates cancelling the draft.

◆ pinConversation()

abstract void pinConversation ( String  conversationID,
boolean  isPinned,
V2TIMCallback  callback 
)
abstract

1.9 Pin a conversion to the top (supported only in 5.3.425 and later versions)

Parameters
conversationIDUnique ID of a conversation. For one-to-one chats, the value format is String.format("c2c_%s", "userID"). For group chats, the value format is String.format("group_%s", "groupID").
isPinnedWhether to pin a conversation to the top

◆ getTotalUnreadMessageCount()

abstract void getTotalUnreadMessageCount ( V2TIMValueCallback< Long >  callback)
abstract

1.10 Get the total message unread count in conversations (supported only in 5.3.425 and later versions)

Attention
  • The total unread message count excludes the unread message count of Do-Not-Disturb conversations (conversations whose message receiving option is V2TIMMessage.V2TIM_NOT_RECEIVE_MESSAGE or V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE).