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

Detailed Description

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

Public Member Functions

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 getConversationListByFilter (V2TIMConversationListFilter filter, long nextSeq, int count, V2TIMValueCallback< V2TIMConversationResult > callback)
 
abstract void deleteConversation (String conversationID, V2TIMCallback callback)
 
abstract void deleteConversationList (List< String > conversationIDList, boolean clearMessage, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 
abstract void setConversationDraft (String conversationID, String draftText, V2TIMCallback callback)
 
abstract void setConversationCustomData (List< String > conversationIDList, String customData, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 
abstract void pinConversation (String conversationID, boolean isPinned, V2TIMCallback callback)
 
abstract void markConversation (List< String > conversationIDList, long markType, boolean enableMark, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 
abstract void getTotalUnreadMessageCount (V2TIMValueCallback< Long > callback)
 
abstract void getUnreadMessageCountByFilter (V2TIMConversationListFilter filter, V2TIMValueCallback< Long > callback)
 
abstract void subscribeUnreadMessageCountByFilter (V2TIMConversationListFilter filter)
 
abstract void unsubscribeUnreadMessageCountByFilter (V2TIMConversationListFilter filter)
 
abstract void cleanConversationUnreadMessageCount (String conversationID, long cleanTimestamp, long cleanSequence, V2TIMCallback callback)
 
abstract void setConversationListener (V2TIMConversationListener listener)
 
abstract void createConversationGroup (String groupName, List< String > conversationIDList, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 
abstract void getConversationGroupList (V2TIMValueCallback< List< String >> callback)
 
abstract void deleteConversationGroup (String groupName, V2TIMCallback callback)
 
abstract void renameConversationGroup (String oldName, String newName, V2TIMCallback callback)
 
abstract void addConversationsToGroup (String groupName, List< String > conversationIDList, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 
abstract void deleteConversationsFromGroup (String groupName, List< String > conversationIDList, V2TIMValueCallback< List< V2TIMConversationOperationResult >> callback)
 

Member Function Documentation

◆ addConversationListener()

abstract void addConversationListener ( V2TIMConversationListener  listener)
abstract

1.1 Add the conversation listener

◆ removeConversationListener()

abstract void removeConversationListener ( V2TIMConversationListener  listener)
abstract

1.2 Remove the conversation listener

◆ getConversationList() [1/2]

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

1.3 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.4 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.5 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").

◆ getConversationListByFilter()

abstract void getConversationListByFilter ( V2TIMConversationListFilter  filter,
long  nextSeq,
int  count,
V2TIMValueCallback< V2TIMConversationResult callback 
)
abstract

1.6 Get the conversation list (advanced API,supported only in 6.5 and later versions)

Parameters
filterconversation filter
nextSeqThe next pulling-by-page cursor
countNumber of conversations to be pulled

◆ 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.

◆ deleteConversationList()

abstract void deleteConversationList ( List< String >  conversationIDList,
boolean  clearMessage,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

1.8 Delete the conversation list (Supported only in 7.1 and later versions)

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").
clearMessageWhether to delete messages in the conversation; when set to false, retain the messages; when set to true, the local and server messages will be deleted together and cannot be reverted
Attention
A maximum of 100 conversations are supported at a time.

◆ setConversationDraft()

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

1.9 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.

◆ setConversationCustomData()

abstract void setConversationCustomData ( List< String >  conversationIDList,
String  customData,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

1.10 Set conversation custom data(supported only in 6.5 and later versions)

Parameters
customDataMaximum support 256 bytes

◆ pinConversation()

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

1.11 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

◆ markConversation()

abstract void markConversation ( List< String >  conversationIDList,
long  markType,
boolean  enableMark,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

1.12 Mark conversation(supported only in 6.5 and later versions, need to buy Flagship Edition)

Parameters
conversationIDListconversation list
markTypemark type of the conversation. For the value, see the V2TIMConversation definition.
enableMarktrue:mark false:unmark

If the existing mark does not meet your needs, you can customize the extension mark. The extension mark needs to meet the following two conditions:

1、Extended mark values must not conflict with existing mark values in V2TIMConversation

2、Extended mark values must be a 0x1L << n (32 <= n < 64, that is, n must be greater than or equal to 32 and less than 64), such as the extension mark value 0x1L << 32 means "iPhone online".

Attention
: The extension mark value cannot be set to 0x1 << 32, it must be set to 0x1L << 32, which explicitly tells the compiler that it is a 64-bit integer constant.

◆ getTotalUnreadMessageCount()

abstract void getTotalUnreadMessageCount ( V2TIMValueCallback< Long >  callback)
abstract

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

Attention
  • After you call this API to obtain the total count of unread messages for all conversations, the newest value will be notified to you through the onTotalUnreadMessageCountChanged callback when unread message count of any conversation changed.
  • 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).

◆ getUnreadMessageCountByFilter()

abstract void getUnreadMessageCountByFilter ( V2TIMConversationListFilter  filter,
V2TIMValueCallback< Long >  callback 
)
abstract

1.14 Get the total message unread count of conversations by filter (supported only in 7.0 and later versions)

Parameters
filterconversation filter
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).

◆ subscribeUnreadMessageCountByFilter()

abstract void subscribeUnreadMessageCountByFilter ( V2TIMConversationListFilter  filter)
abstract

1.15 Subscribe changing notification of total unread message count for conversations specified by filter parameter.(supported only in 7.0 and later versions)

Parameters
filterconversation filter
Attention
  • After you call this API, the newest value of total unread message count for conversations that match the filter parameter will be notified to you through the onUnreadMessageCountChangedByFilter callback.

◆ unsubscribeUnreadMessageCountByFilter()

abstract void unsubscribeUnreadMessageCountByFilter ( V2TIMConversationListFilter  filter)
abstract

1.16 Unsubscribe changing notification of total unread message count for conversations specified by filter parameter.(supported only in 7.0 and later versions)

Parameters
filterconversation filter

◆ cleanConversationUnreadMessageCount()

abstract void cleanConversationUnreadMessageCount ( String  conversationID,
long  cleanTimestamp,
long  cleanSequence,
V2TIMCallback  callback 
)
abstract

1.17 Clean up the unread message count of the conversation (supported only in 7.1 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").
cleanTimestampThe specified timestamp in seconds that needs to be cleared (only valid for one-to-one chats). The count of unread messages before the specified timestamp will be cleared, and when the value is 0, all unread messages of the corresponding conversation will be cleared, and the unread message count of the corresponding conversation will be set to 0.
cleanSequenceThe specified sequence that needs to be cleared (only valid for group chats). The count of unread messages before the specified sequence will be cleared, and when the value is 0, all unread messages of the corresponding conversation will be cleared, and the unread message count of the corresponding conversation will be set to 0.
Attention
  • When you want to clear unread messages count of all one-on-one conversations, please input conversationID with value "c2c", i.e., don't specify the userID;
  • When you want to clear unread messages count of all group conversations, please input conversationID with value "group", i.e., don't specify the groupID;
  • When you want to clear unread messages count of all conversations,please input conversationID with value "" or null;
  • After the API is successfully called, you will receive the onConversationChanged callback that carries the latest unread message number of the corresponding conversation.

◆ setConversationListener()

abstract void setConversationListener ( V2TIMConversationListener  listener)
abstract

1.18 Set the conversation listener

◆ createConversationGroup()

abstract void createConversationGroup ( String  groupName,
List< String >  conversationIDList,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

2.1 Create a conversation group.

Parameters
groupNamegroup name(Required parameters, length must be greater than 0, maximum support 32 bytes)
conversationIDListconversation ID list(Required parameters,can not be empty)
Attention
: A maximum of 20 conversation groups are supported. Please delete the groups that are no longer in use.

◆ getConversationGroupList()

abstract void getConversationGroupList ( V2TIMValueCallback< List< String >>  callback)
abstract

2.2 Get a list of conversation groups.

◆ deleteConversationGroup()

abstract void deleteConversationGroup ( String  groupName,
V2TIMCallback  callback 
)
abstract

2.3 Delete a conversation group.

◆ renameConversationGroup()

abstract void renameConversationGroup ( String  oldName,
String  newName,
V2TIMCallback  callback 
)
abstract

2.4 Rename a conversation group.

◆ addConversationsToGroup()

abstract void addConversationsToGroup ( String  groupName,
List< String >  conversationIDList,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

2.5 Add conversation list to a group.

◆ deleteConversationsFromGroup()

abstract void deleteConversationsFromGroup ( String  groupName,
List< String >  conversationIDList,
V2TIMValueCallback< List< V2TIMConversationOperationResult >>  callback 
)
abstract

2.6 Delete conversation list from a group.