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.
V2TIMManager(Conversation)

Instance Methods

(void) - addConversationListener:
 
(void) - removeConversationListener:
 
(void) - getConversationList:count:succ:fail:
 
(void) - getConversation:succ:fail:
 
(void) - getConversationList:succ:fail:
 
(void) - deleteConversation:succ:fail:
 
(void) - setConversationDraft:draftText:succ:fail:
 
(void) - pinConversation:isPinned:succ:fail:
 
(void) - getTotalUnreadMessageCount:fail:
 
(void) - setConversationListener:
 

Protected Types

enum  V2TIMConversationType : NSInteger
 
enum  V2TIMGroupAtType : NSInteger
 
typedef void(^ V2TIMConversationResultSucc) (NSArray< V2TIMConversation * > *list, uint64_t nextSeq, BOOL isFinished)
 
typedef void(^ V2TIMConversationSucc) (V2TIMConversation *conv)
 
typedef void(^ V2TIMConversationListSucc) (NSArray< V2TIMConversation * > *list)
 
typedef void(^ V2TIMTotalUnreadMessageCountSucc) (UInt64 totalCount)
 

Member Typedef Documentation

◆ V2TIMConversationResultSucc

- (typedef void(^ V2TIMConversationResultSucc) (NSArray< V2TIMConversation * > *list, uint64_t nextSeq, BOOL isFinished))
protected

Callback definition on get conversation list successfully.

◆ V2TIMConversationSucc

- (typedef void(^ V2TIMConversationSucc) (V2TIMConversation *conv))
protected

Callback definition on get single conversation successfully.

◆ V2TIMConversationListSucc

- (typedef void(^ V2TIMConversationListSucc) (NSArray< V2TIMConversation * > *list))
protected

Callback definition on get specified conversation list successfully.

◆ V2TIMTotalUnreadMessageCountSucc

- (typedef void(^ V2TIMTotalUnreadMessageCountSucc) (UInt64 totalCount))
protected

Callback definition on get total count of unread messages successfully.

Member Enumeration Documentation

◆ V2TIMConversationType

- (enum V2TIMConversationType) :
protected

Enumeration definition of conversation type.

Enumerator
V2TIM_C2C 

One-to-one chat.

V2TIM_GROUP 

Group chat.

◆ V2TIMGroupAtType

- (enum V2TIMGroupAtType) :
protected

Enumeration definition of @ type.

Enumerator
V2TIM_AT_ME 

@me

V2TIM_AT_ALL 

@all

V2TIM_AT_ALL_AT_ME 

@all in the group and @me alone

Method Documentation

◆ addConversationListener:()

- (void) addConversationListener: (addConversationListener(listener:))  NS_SWIFT_NAME

1.1 Add the conversation listener

◆ removeConversationListener:()

- (void) removeConversationListener: (removeConversationListener(listener:))  NS_SWIFT_NAME

1.2 Remove the conversation listener

◆ getConversationList:count:succ:fail:()

- (void) getConversationList: (uint64_t)  nextSeq
count: (int)  count
succ: (V2TIMConversationResultSucc succ
fail: (V2TIMFail)  fail 

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:succ:fail:()

- (void) getConversation: (NSString *)  conversationID
succ: (V2TIMConversationSucc succ
fail: (V2TIMFail)  fail 

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:succ:fail:()

- (void) getConversationList: (NSArray< NSString * > *)  conversationIDList
succ: (V2TIMConversationListSucc succ
fail: (V2TIMFail)  fail 

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").

◆ deleteConversation:succ:fail:()

- (void) deleteConversation: (NSString *)  conversationID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

1.6 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:draftText:succ:fail:()

- (void) setConversationDraft: (NSString *)  conversationID
draftText: (NSString *)  draftText
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

1.7 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").
draftTextDraft content. The value null indicates cancelling the draft.
Attention
Notes: 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.

◆ pinConversation:isPinned:succ:fail:()

- (void) pinConversation: (NSString *)  conversationID
isPinned: (BOOL)  isPinned
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

1.8 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:fail:()

- (void) getTotalUnreadMessageCount: (V2TIMTotalUnreadMessageCountSucc succ
fail: (V2TIMFail)  fail 

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

◆ setConversationListener:()

- (void) setConversationListener: (id< V2TIMConversationListener >)  listener

Set the conversation listener

Attention
It is deprecated and discouraged to call this function. Please call APIs ref addConversationListener and removeConversationListener instead.