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(Message)

Instance Methods

(void) - addAdvancedMsgListener:
 
(void) - removeAdvancedMsgListener:
 
(V2TIMMessage *) - createTextMessage:
 
(V2TIMMessage *) - createTextAtMessage:atUserList:
 
(V2TIMMessage *) - createCustomMessage:
 
(V2TIMMessage *) - createCustomMessage:desc:extension:
 
(V2TIMMessage *) - createImageMessage:
 
(V2TIMMessage *) - createSoundMessage:duration:
 
(V2TIMMessage *) - createVideoMessage:type:duration:snapshotPath:
 
(V2TIMMessage *) - createFileMessage:fileName:
 
(V2TIMMessage *) - createLocationMessage:longitude:latitude:
 
(V2TIMMessage *) - createFaceMessage:data:
 
(V2TIMMessage *) - createMergerMessage:title:abstractList:compatibleText:
 
(V2TIMMessage *) - createForwardMessage:
 
(V2TIMMessage *) - createTargetedGroupMessage:receiverList:
 
(V2TIMMessage *) - createAtSignedGroupMessage:atUserList:
 
(NSString *) - sendMessage:receiver:groupID:priority:onlineUserOnly:offlinePushInfo:progress:succ:fail:
 
(void) - setC2CReceiveMessageOpt:opt:succ:fail:
 
(void) - getC2CReceiveMessageOpt:succ:fail:
 
(void) - setGroupReceiveMessageOpt:opt:succ:fail:
 
(void) - setAllReceiveMessageOpt:startHour:startMinute:startSecond:duration:succ:fail:
 
(void) - setAllReceiveMessageOpt:startTimeStamp:duration:succ:fail:
 
(void) - getAllReceiveMessageOpt:fail:
 
(void) - getC2CHistoryMessageList:count:lastMsg:succ:fail:
 
(void) - getGroupHistoryMessageList:count:lastMsg:succ:fail:
 
(void) - getHistoryMessageList:succ:fail:
 
(void) - revokeMessage:succ:fail:
 
(void) - modifyMessage:completion:
 
(void) - deleteMessageFromLocalStorage:succ:fail:
 
(void) - deleteMessages:succ:fail:
 
(void) - clearC2CHistoryMessage:succ:fail:
 
(void) - clearGroupHistoryMessage:succ:fail:
 
(NSString *) - insertGroupMessageToLocalStorage:to:sender:succ:fail:
 
(NSString *) - insertC2CMessageToLocalStorage:to:sender:succ:fail:
 
(void) - findMessages:succ:fail:
 
(void) - searchLocalMessages:succ:fail:
 
(void) - searchCloudMessages:succ:fail:
 
(void) - sendMessageReadReceipts:succ:fail:
 
(void) - getMessageReadReceipts:succ:fail:
 
(void) - getGroupMessageReadMemberList:filter:nextSeq:count:succ:fail:
 
(void) - setMessageExtensions:extensions:succ:fail:
 
(void) - getMessageExtensions:succ:fail:
 
(void) - deleteMessageExtensions:keys:succ:fail:
 
(void) - addMessageReaction:reactionID:succ:fail:
 
(void) - removeMessageReaction:reactionID:succ:fail:
 
(void) - getMessageReactions:maxUserCountPerReaction:succ:fail:
 
(void) - getAllUserListOfMessageReaction:reactionID:nextSeq:count:succ:fail:
 
(void) - translateText:sourceLanguage:targetLanguage:completion:
 
(void) - markC2CMessageAsRead:succ:fail:
 
(void) - markGroupMessageAsRead:succ:fail:
 
(void) - markAllMessageAsRead:fail:
 

Member Typedef Documentation

◆ V2TIMMessageListSucc

- (typedef void(^ V2TIMMessageListSucc) (NSArray< V2TIMMessage * > *msgs))
protected

Callback definition on get history message list.

◆ V2TIMSearchMessageListSucc

- (typedef void(^ V2TIMSearchMessageListSucc) (V2TIMMessageSearchResult *searchResult))
protected

Callback definition on search history message.

◆ V2TIMProgress

- (typedef void(^ V2TIMProgress) (uint32_t progress))
protected

Callback definition for file upload progress.

◆ V2TIMDownLoadProgress

- (typedef void(^ V2TIMDownLoadProgress) (NSInteger curSize, NSInteger totalSize))
protected

Callback definition for file download progress.

◆ V2TIMReceiveMessageOptListSucc

- (typedef void(^ V2TIMReceiveMessageOptListSucc) (NSArray< V2TIMReceiveMessageOptInfo * > *optList))
protected

Callback definition for get message receive option.

◆ V2TIMReceiveMessageOptSucc

- (typedef void(^ V2TIMReceiveMessageOptSucc) (V2TIMReceiveMessageOptInfo *optInfo))
protected

Callback definition for get all message receive option.

◆ V2TIMMessageReadReceiptsSucc

- (typedef void(^ V2TIMMessageReadReceiptsSucc) (NSArray< V2TIMMessageReceipt * > *receiptList))
protected

Callback definition for get receipt for group message.

◆ V2TIMGroupMessageReadMemberListSucc

- (typedef void(^ V2TIMGroupMessageReadMemberListSucc) (NSMutableArray< V2TIMGroupMemberInfo * > *members, uint64_t nextSeq, BOOL isFinished))
protected

Callback definition for get read or unread members for group message.

◆ V2TIMMessageModifyCompletion

- (typedef void(^ V2TIMMessageModifyCompletion) (int code, NSString *desc, V2TIMMessage *msg))
protected

Callback definition for message modification completed.

◆ V2TIMMessageExtensionsSetSucc

- (typedef void(^ V2TIMMessageExtensionsSetSucc) (NSArray< V2TIMMessageExtensionResult * > *extensionResultList))
protected

Callback definition for set message extensions.

◆ V2TIMMessageExtensionsGetSucc

- (typedef void(^ V2TIMMessageExtensionsGetSucc) (NSArray< V2TIMMessageExtension * > *extensionList))
protected

Callback definition for get message extensions.

◆ V2TIMMessageExtensionsDeleteSucc

- (typedef void(^ V2TIMMessageExtensionsDeleteSucc) (NSArray< V2TIMMessageExtensionResult * > *extensionResultList))
protected

Callback definition for delete message extensions.

◆ V2TIMGetMessageReactionsSucc

- (typedef void(^ V2TIMGetMessageReactionsSucc) (NSArray< V2TIMMessageReactionResult * > *resultList))
protected

Callback definition for get message reactions.

◆ V2TIMGetMessageReactionUserListSucc

- (typedef void(^ V2TIMGetMessageReactionUserListSucc) (NSArray< V2TIMUserInfo * > *userList, uint32_t nextSeq, BOOL isFinished))
protected

Callback definition for get message reaction user list.

Member Enumeration Documentation

◆ V2TIMMessageStatus

- (enum V2TIMMessageStatus) :
protected

Enumeration definition of message status.

Enumerator
V2TIM_MSG_STATUS_SENDING 

Message being sent.

V2TIM_MSG_STATUS_SEND_SUCC 

Message sent successfully.

V2TIM_MSG_STATUS_SEND_FAIL 

Message fails to be sent.

V2TIM_MSG_STATUS_HAS_DELETED 

Message deleted.

V2TIM_MSG_STATUS_LOCAL_IMPORTED 

Message imported to local storage.

V2TIM_MSG_STATUS_LOCAL_REVOKED 

Message revoked.

◆ V2TIMElemType

- (enum V2TIMElemType) :
protected

Enumeration definition of message element type.

Enumerator
V2TIM_ELEM_TYPE_NONE 

No element.

V2TIM_ELEM_TYPE_TEXT 

Text message.

V2TIM_ELEM_TYPE_CUSTOM 

Custom message.

V2TIM_ELEM_TYPE_IMAGE 

Image message.

V2TIM_ELEM_TYPE_SOUND 

Voice message.

V2TIM_ELEM_TYPE_VIDEO 

Video message.

V2TIM_ELEM_TYPE_FILE 

File message.

V2TIM_ELEM_TYPE_LOCATION 

Geographical location message.

V2TIM_ELEM_TYPE_FACE 

Emoji message.

V2TIM_ELEM_TYPE_GROUP_TIPS 

Group tip message.

V2TIM_ELEM_TYPE_MERGER 

Forward message.

◆ V2TIMOfflinePushFlag

- (enum V2TIMOfflinePushFlag) :
protected

Enumeration definition of offline push flag.

Enumerator
V2TIM_OFFLINE_PUSH_DEFAULT 

Push mesage when offline according to the default rules.

V2TIM_OFFLINE_PUSH_NO_PUSH 

Don't push mesage when offline.

◆ V2TIMImageType

- (enum V2TIMImageType) :
protected

Enumeration definition of image type.

Enumerator
V2TIM_IMAGE_TYPE_ORIGIN 

Original image.

V2TIM_IMAGE_TYPE_THUMB 

Thumbnail.

V2TIM_IMAGE_TYPE_LARGE 

Large image.

◆ V2TIMGroupTipsType

- (enum V2TIMGroupTipsType) :
protected

Enumeration definition of group tip type.

Enumerator
V2TIM_GROUP_TIPS_TYPE_JOIN 

Proactively join a group (memberList joins a group; valid only for non-Work groups)

V2TIM_GROUP_TIPS_TYPE_INVITE 

Be invited to a group (opMember invites memberList to join a group; valid only for Work groups)

V2TIM_GROUP_TIPS_TYPE_QUIT 

Quit a group.

V2TIM_GROUP_TIPS_TYPE_KICKED 

Be kicked out of a group (opMember kicks memberList out of the group)

V2TIM_GROUP_TIPS_TYPE_SET_ADMIN 

Set an admin (opMember sets memberList as an admin)

V2TIM_GROUP_TIPS_TYPE_CANCEL_ADMIN 

Cancel an admin (opMember cancels memberList as an admin)

V2TIM_GROUP_TIPS_TYPE_GROUP_INFO_CHANGE 

Group profile change (opMember modifies group information:groupName & introduction & notification & faceUrl & owner & allMute & custom)

V2TIM_GROUP_TIPS_TYPE_MEMBER_INFO_CHANGE 

Group member profile change (opMember modifies group member information:muteTime)

V2TIM_GROUP_TIPS_TYPE_TOPIC_INFO_CHANGE 

Topic profile change(opMember modifies topic information:topicName & introduction & notification & faceUrl & allMute & topicCustomData)

◆ V2TIMGroupInfoChangeType

- (enum V2TIMGroupInfoChangeType) :
protected

Enumeration definition of change type to group information.

Enumerator
V2TIM_GROUP_INFO_CHANGE_TYPE_NAME 

Change the group name.

V2TIM_GROUP_INFO_CHANGE_TYPE_INTRODUCTION 

Modify the group introduction.

V2TIM_GROUP_INFO_CHANGE_TYPE_NOTIFICATION 

Modify the group notice.

V2TIM_GROUP_INFO_CHANGE_TYPE_FACE 

Modify the group profile photo.

V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER 

Change the group owner.

V2TIM_GROUP_INFO_CHANGE_TYPE_CUSTOM 

Change the custom group field.

V2TIM_GROUP_INFO_CHANGE_TYPE_SHUT_UP_ALL 

Change the group muting field.

V2TIM_GROUP_INFO_CHANGE_TYPE_TOPIC_CUSTOM_DATA 

Change the topic custom data field.

V2TIM_GROUP_INFO_CHANGE_TYPE_RECEIVE_MESSAGE_OPT 

Change the group receive message option field.

V2TIM_GROUP_INFO_CHANGE_TYPE_GROUP_ADD_OPT 

In the mode of applying to join the group, the administrator approval option has changed.

V2TIM_GROUP_INFO_CHANGE_TYPE_GROUP_APPROVE_OPT 

In the mode of inviting into the group, the administrator's approval option has changed.

V2TIM_GROUP_INFO_CHANGE_TYPE_ENABLE_PERMISSION_GROUP 

Enable permission group field.

V2TIM_GROUP_INFO_CHANGE_TYPE_DEFAULT_PERMISSIONS 

Change the group default permissions field.

◆ V2TIMMessageGetType

- (enum V2TIMMessageGetType) :
protected

Enumeration definition of message pull type.

Enumerator
V2TIM_GET_CLOUD_OLDER_MSG 

Get older messages from the cloud.

V2TIM_GET_CLOUD_NEWER_MSG 

Get newer messages from the cloud.

V2TIM_GET_LOCAL_OLDER_MSG 

Get older messages from local storage.

V2TIM_GET_LOCAL_NEWER_MSG 

Get newer messages from local storage.

◆ V2TIMReceiveMessageOpt

- (enum V2TIMReceiveMessageOpt) :
protected

Enumeration definition of message receive option.

Enumerator
V2TIM_RECEIVE_MESSAGE 

Messages will be received when the user is online, and offline push notifications will be received when the user is offline.

V2TIM_NOT_RECEIVE_MESSAGE 

No message will be received.

V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE 

Messages will be received when the user is online, and no push notification will be received when the user is offline.

◆ V2TIMKeywordListMatchType

- (enum V2TIMKeywordListMatchType) :
protected

Enumeration definition of keyword list matching type when search message.

Enumerator
V2TIM_KEYWORD_LIST_MATCH_TYPE_OR 
V2TIM_KEYWORD_LIST_MATCH_TYPE_AND 

◆ V2TIMGroupMessageReadMembersFilter

- (enum V2TIMGroupMessageReadMembersFilter) :
protected

Group message read member list filter type.

Enumerator
V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ 

Group message read member list.

V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD 

Group message unread member list.

◆ V2TIMIOSOfflinePushType

- (enum V2TIMIOSOfflinePushType) :
protected

The type of offline push on iOS.

Enumerator
V2TIM_IOS_OFFLINE_PUSH_TYPE_APNS 

APNs.

V2TIM_IOS_OFFLINE_PUSH_TYPE_VOIP 

VoIP push.

Method Documentation

◆ addAdvancedMsgListener:()

- (void) addAdvancedMsgListener: (addAdvancedMsgListener(listener:))  NS_SWIFT_NAME

1.1 Add an event listener for advanced messages

◆ removeAdvancedMsgListener:()

- (void) removeAdvancedMsgListener: (removeAdvancedMsgListener(listener:))  NS_SWIFT_NAME

1.2 Remove the event listener for advanced messages

◆ createTextMessage:()

- (V2TIMMessage *) createTextMessage: (NSString *)  text

2.1 Create a text message

◆ createTextAtMessage:atUserList:()

- (V2TIMMessage *) createTextAtMessage: (NSString *)  text
atUserList: (NSMutableArray< NSString * > *)  atUserList 

2.2 Create a text message with the @ notification feature

Notification messages are only applicable to messages sent in the group.

Parameters
atUserListList of @ target users. To @all, please pass in the kImSDK_MesssageAtALL constant string. For example, if you want the current text message to @denny, @lucy, and @all, pass in @["denny", @"lucy", kImSDK_MesssageAtALL] for atUserList.
Attention
The following are use limits for atUserList:
  • The maximum number of @ target users is 30 by default. If this limit is exceeded, message sending will fail.
  • The total number of users specified by atUserList cannot exceed the default maximum number, including the case of @all.
  • AVChatRoom do not support sending @ messages.

◆ createCustomMessage:()

- (V2TIMMessage *) createCustomMessage: (NSData *)  data

2.3 Create a custom message

◆ createCustomMessage:desc:extension:()

- (V2TIMMessage *) createCustomMessage: (NSData *)  data
desc: (NSString *)  desc
extension: (createCustomMessage(data:desc:ext:))  NS_SWIFT_NAME 

2.4 Create a custom message and set offline push information

Parameters
descCustom message description information to be displayed in text during offline push
extensionExtension field information during offline push

◆ createImageMessage:()

- (V2TIMMessage *) createImageMessage: (NSString *)  imagePath

2.5 Create an image message (image size limit: 28 MB)

◆ createSoundMessage:duration:()

- (V2TIMMessage *) createSoundMessage: (NSString *)  audioFilePath
duration: (int)  duration 

2.6 Create a voice message (voice size limit: 28 MB)

Parameters
durationVoice duration, in seconds

◆ createVideoMessage:type:duration:snapshotPath:()

- (V2TIMMessage *) createVideoMessage: (NSString *)  videoFilePath
type: (NSString *)  type
duration: (int)  duration
snapshotPath: (NSString *)  snapshotPath 

2.7 Create a video message (video size limit: 100 MB)

Parameters
typeVideo type, such as mp4 and mov
durationVideo duration, in seconds
snapshotPathVideo cover image path

◆ createFileMessage:fileName:()

- (V2TIMMessage *) createFileMessage: (NSString *)  filePath
fileName: (NSString *)  fileName 

2.8 Create a file message (file size limit: 100 MB)

◆ createLocationMessage:longitude:latitude:()

- (V2TIMMessage *) createLocationMessage: (NSString *)  desc
longitude: (double)  longitude
latitude: (double)  latitude 

2.9 Create a location message

◆ createFaceMessage:data:()

- (V2TIMMessage *) createFaceMessage: (int)  index
data: (NSData *)  data 

2.10 Create an emoji message

The IM SDK does not provide an emoji package. Developers can use index to store the indexes of the emojis they have in their emoji packages. Alternatively, they can directly use data to store emoji binary data and the string key. Either way, developers can customize emojis. The IM SDK is only responsible for passing them through.

Parameters
indexEmoji index
dataCustom data

◆ createMergerMessage:title:abstractList:compatibleText:()

- (V2TIMMessage *) createMergerMessage: (NSArray< V2TIMMessage * > *)  messageList
title: (NSString *)  title
abstractList: (NSArray< NSString * > *)  abstractList
compatibleText: (NSString *)  compatibleText 

2.11 Create a combined message (supported only in 5.2.210 and later versions)

Usually when we receive a combined message, the chat screen will look like this:

|Chat History of Vinson and Lynx | – title (Title)

|Vinson: When is the new version of SDK scheduled to go online? | – abstract1 (Digest information 1)

|Lynx: Next Monday. The specific time depends on the system test result in these two days. | – abstract2 (Digest information 2)

|Vinson: OK | – abstract3 (Digest information 3)

The chat UI usually displays only the title and digest information of the combined message, and the complete combined message list will be displayed only when the user clicks the combined message on the UI.

You can create a combined message (V2TIMMessage) for multiple messages to be forwarded and call the sendMessage API to send the combined message. The procedure is as follows:

1. Call createMergerMessage to create a combined message V2TIMMessage.

2. Call sendMessage to send the forward message V2TIMMessage.

The procedure for parsing a combined message received is as follows:

1. Obtain mergerElem via V2TIMMessage.

2. Obtain title and abstractList via mergerElem for UI display.

3. When a user clicks the digest information on the UI, call downloadMessageList to get the list of forwarded messages.

Parameters
messageListMessage list (Up to 300 messages are supported. The message object must be in the V2TIM_MSG_STATUS_SEND_SUCC status. The message type cannot be V2TIMGroupTipsElem.)
titleSource of the combined message, for example, "Chat History of Vinson and Lynx" and "xxx group chat history"
abstractListCombined message digest list (supports up to 5 digests, each containing a maximum of 100 characters) You can set digest information in different formats for different message types, for example: For a text message, the digest can be in the "sender:text" format. For an image message, the digest can be in the "sender:[image]" format. For a file message, the digest can be in the "sender:[file]" format.
compatibleTextCombined messages are compatible with text. SDKs of early versions do not support combined messages, and they will send a text message with the content compatibleText by default. The parameter cannot be null.

◆ createForwardMessage:()

- (V2TIMMessage *) createForwardMessage: (V2TIMMessage *)  message

2.12 Create a forward message (supported only in 5.2.210 and later versions)

If you need to forward a message, you cannot directly call the sendMessage API to send the original message. Instead, you need to call createForwardMessage to create a forward message first and send it.

Parameters
messageMessage object to be forwarded. The message status must be V2TIM_MSG_STATUS_SEND_SUCC. The message type cannot be V2TIMGroupTipsElem.
Returns
Forward message object. The elem content is the same as the original message.

◆ createTargetedGroupMessage:receiverList:()

- (V2TIMMessage *) createTargetedGroupMessage: (V2TIMMessage *)  message
receiverList: (NSMutableArray< NSString * > *)  receiverList 

2.13 Create a targeted group message(supported only in 6.0 and later versions)

If you need to send a message to a specified group member list within a group, you can create a targeted group message. Only the specified group member can receive the targeted group message.

Parameters
messageOriginal message object
receiverListMessage receivers
Returns
Targeted group message object
Attention
Please note:
  • The original message object does not support group @ message.
  • The message receiver list supports up to 50.
  • The targeted group message cannot be sent in community group and avchatroom group.
  • The targeted group message will not be counted into the count of unread message for a group conversation.

◆ createAtSignedGroupMessage:atUserList:()

- (V2TIMMessage *) createAtSignedGroupMessage: (V2TIMMessage *)  message
atUserList: (NSMutableArray< NSString * > *)  atUserList 

2.14 Create a @ signed group message(supported only in 7.0 and later versions)

If you need to send a group message with @ notification feature, you can create a @ signed group message.

Parameters
messageOriginal message object
atUserListList of @ target users. To @all, please pass in the kImSDK_MesssageAtALL constant string. For example, if you want the current message to @denny, @lucy, and @all, pass in @["denny", @"lucy", kImSDK_MesssageAtALL] for atUserList.
Returns
Group @ message object
Attention
The following are use limits for atUserList:
  • The maximum number of @ target users is 30 by default. If this limit is exceeded, message sending will fail.
  • The total number of users specified by atUserList cannot exceed the default maximum number, including the case of @all.
  • AVChatRoom do not support sending @ messages.

◆ sendMessage:receiver:groupID:priority:onlineUserOnly:offlinePushInfo:progress:succ:fail:()

- (NSString *) sendMessage: (V2TIMMessage *)  message
receiver: (NSString *)  receiver
groupID: (NSString *)  groupID
priority: (V2TIMMessagePriority)  priority
onlineUserOnly: (BOOL)  onlineUserOnly
offlinePushInfo: (V2TIMOfflinePushInfo *)  offlinePushInfo
progress: (V2TIMProgress progress
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

3.1 Send an advanced message (advanced version: provides the features of specifying message priorities and push information)

Parameters
messageMessage object to be sent, which needs to be created via the corresponding message creation API
receiverMessage recipient's userID. For a one-to-one message, you only need to specify this field.
groupIDTarget group ID For a group chat message, you only need to specify this field.
priorityMessage priorities. This field is valid only for group chat messages. You are advised to set higher priorities for important messages (such as red packet and gift messages) and set lower priorities for frequent but unimportant messages (such as like messages).
onlineUserOnlyWhether the message can be received only by online users. If this field is set to true, the message cannot be pulled in recipient historical message pulling. This field is often used to implement weak notification features such as "The other party is typing" or unimportant notifications in the group. This field is not supported by audio-video groups (AVChatRoom).
offlinePushInfoTitle and voice carried when the message pushing offline.
Returns
msgID Unique ID of the message
Attention
  • Targeted group messages are supported in version 6.0 and later. If groupID and receiver are set at the same time, the message will be sent to the specified receiver in the group. If you want to send message to multiple receivers in a group, you need to call createTargetedGroupMessage API to create a targeted group message with multiple receivers before sending.
  • Before setting the offlinePushInfo field, you need to enable push via V2TIMOfflinePushManager. After push is enabled, all messages except custom messages will be pushed by default.
  • If you want to push custom messages as well, set the desc field in offlinePushInfo so that the information specified by desc will be displayed by default during push.
  • Audio-video groups (AVChatRoom) do not support the onlineUserOnly field. You need to set onlineUserOnly to false for audio-video groups (AVChatRoom).
  • If onlineUserOnly is set to true, the message is an online message and is not counted as an unread message.

◆ setC2CReceiveMessageOpt:opt:succ:fail:()

- (void) setC2CReceiveMessageOpt: (NSArray< NSString * > *)  userIDList
opt: (V2TIMReceiveMessageOpt opt
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

4.1 Set the one-to-one message receiving option for specified users (batch setting supported)

Supported only in 5.3.425 and later versions.

Attention
Notes:
  • This API supports batch setting. You can use the userIDList field to specify up to 30 users for batch setting.
  • This API can be called for up to 5 times per second.
Parameters
optThere are three message receiving options: V2TIMMessage.V2TIM_RECEIVE_MESSAGE: messages will be received when the user is online, and push notifications will be received when the user is offline. V2TIMMessage.V2TIM_NOT_RECEIVE_MESSAGE: no message will be received. V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE: messages will be received when the user is online, and no push notification will be received when the user is offline.

◆ getC2CReceiveMessageOpt:succ:fail:()

- (void) getC2CReceiveMessageOpt: (NSArray< NSString * > *)  userIDList
succ: (V2TIMReceiveMessageOptListSucc succ
fail: (V2TIMFail)  fail 

4.2 Query the one-to-one message receiving option for specified users

Supported only in 5.3.425 and later versions.

◆ setGroupReceiveMessageOpt:opt:succ:fail:()

- (void) setGroupReceiveMessageOpt: (NSString *)  groupID
opt: (V2TIMReceiveMessageOpt opt
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

4.3 Set the group message receiving option

◆ setAllReceiveMessageOpt:startHour:startMinute:startSecond:duration:succ:fail:()

- (void) setAllReceiveMessageOpt: (V2TIMReceiveMessageOpt opt
startHour: (int32_t)  startHour
startMinute: (int32_t)  startMinute
startSecond: (int32_t)  startSecond
duration: (uint32_t)  duration
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

4.4 Set message receiving option for all conversations,supported only in 7.4 and later versions.

Parameters
optThere are two message receiving options for you to choose: V2TIMReceiveMessageOpt.V2TIM_RECEIVE_MESSAGE:messages will be received when the user is online, and notifications will be received when the user is offline. V2TIMReceiveMessageOpt.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE:messages will be received when the user is online, and no push notification will be received when the user is offline.(It can be used to implement the user's do not disturb function)
startHour(0 - 23) The hour field of the start time for do not disturb function
startMinute(0 - 59) The minute field of the start time for do not disturb function
startSecond(0 - 59) The second field of the start time for do not disturb function
duration(0 - 24*60*60) Duration for do not disturb function, unit: second
Attention
Notes.
  • When the value of duration is less than 24*60*60, it can be used to implement "Repeated Do Not Disturb" which means the Message Do Not Disturb starts from the time point represented by "startHour:startMinute:startSecond" every day and durations for specified interval represented by this field.
  • When the duration value is not less than 24*60*60, it can be used to achieve "Permanent Do Not Disturb" which means the Message Do Not Disturb starts from the time point represented by "startHour:startMinute:startSecond" and keep going for ever.

◆ setAllReceiveMessageOpt:startTimeStamp:duration:succ:fail:()

- (void) setAllReceiveMessageOpt: (V2TIMReceiveMessageOpt opt
startTimeStamp: (uint32_t)  startTimeStamp
duration: (uint32_t)  duration
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

4.5 Set message receiving option for all conversations,supported only in 7.4 and later versions.

Parameters
optThere are two message receiving options for you to choose: V2TIMReceiveMessageOpt.V2TIM_RECEIVE_MESSAGE:messages will be received when the user is online, and notifications will be received when the user is offline. V2TIMReceiveMessageOpt.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE:messages will be received when the user is online, and no push notification will be received when the user is offline.(It can be used to implement the user's do not disturb function)
startTimeStampThe start time for do not disturb function, UTC timestamp, unit: second
durationDuration for do not disturb function, unit: second

◆ getAllReceiveMessageOpt:fail:()

- (void) getAllReceiveMessageOpt: (V2TIMReceiveMessageOptSucc succ
fail: (V2TIMFail)  fail 

4.6 Get the all Message receiving option,supported only in 7.4 and later versions.

◆ getC2CHistoryMessageList:count:lastMsg:succ:fail:()

- (void) getC2CHistoryMessageList: (NSString *)  userID
count: (int)  count
lastMsg: (V2TIMMessage *)  lastMsg
succ: (V2TIMMessageListSucc succ
fail: (V2TIMFail)  fail 

5.1 Get historical one-to-one messages

Parameters
countNumber of messages pulled at a time. The value of this field cannot be too large; otherwise, the pulling speed is affected. We recommend that you pull 20 messages at a time.
lastMsgStart message for message pulling. If null is passed in, the newest message of the conversation will be considered as the start message.
Attention
Notes:
  • If the login interface is not called,calling this interface will not return any historical messages.
  • If the login is failed, calling this interface will return local historical messages.
  • If the login is successful and the network is disconnected, calling this interface will return local historical messages.
  • If the login is successful and the network is connected, calling this interface will first request cloud historical messages, and then merge them with local historical messages before returning.

◆ getGroupHistoryMessageList:count:lastMsg:succ:fail:()

- (void) getGroupHistoryMessageList: (NSString *)  groupID
count: (int)  count
lastMsg: (V2TIMMessage *)  lastMsg
succ: (V2TIMMessageListSucc succ
fail: (V2TIMFail)  fail 

5.2 Get historical group messages

Parameters
countNumber of messages pulled at a time. The value of this field cannot be too large; otherwise, the pulling speed is affected. We recommend that you pull 20 messages at a time.
lastMsgStart message for message pulling. If null is passed in, the newest message of the conversation will be considered as the start message.
Attention
Notes:
  • If the login interface is not called,calling this interface will not return any historical messages.
  • If the login is failed, calling this interface will return local historical messages.
  • If the login is successful and the network is disconnected, calling this interface will return local historical messages.
  • If the login is successful and the network is connected, calling this interface will first request cloud historical messages, and then merge them with local historical messages before returning.
  • Only meeting groups (Meeting) support pulling historical messages of members before they join the groups. For audio-video groups (AVChatRoom), messages are not saved to the roaming and local databases, and therefore this API does not take effect.

◆ getHistoryMessageList:succ:fail:()

- (void) getHistoryMessageList: (V2TIMMessageListGetOption *)  option
succ: (V2TIMMessageListSucc succ
fail: (V2TIMFail)  fail 

5.3 Get historical messages (advanced API)

Parameters
optionMessage pulling option, which can be set to pull older or newer messages from local storage or the cloud
Attention
Notes:
  • If the login interface is not called,calling this interface will not return any historical messages.
  • If the login is failed, calling this interface will return local historical messages.
  • If the login is successful and the network is disconnected, calling this interface will return local historical messages.
  • If the login is successful and the network is connected, when the option param is set to pull cloud historical messages, calling this interface will first request cloud historical messages, and then merge them with local historical messages before returning.
  • Only meeting groups (Meeting) support pulling historical messages of members before they join the groups. For audio-video groups (AVChatRoom), messages are not saved to the roaming and local databases, and therefore this API does not take effect.

◆ revokeMessage:succ:fail:()

- (void) revokeMessage: (V2TIMMessage *)  msg
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.4 Recall messages

Attention
Notes:
  • By default, you can recall only messages that are sent within 2 minutes. You can customize the time limit for message recall via the console (Feature Configuration -> Login and Message -> Message Recall Settings).
  • Only common messages sent in one-to-one chats and group chats can be recalled. Messages that can be received only by online users (onlineUserOnly is set to true) cannot be recalled.
  • If the sender recalls a message, the recipient will receive the V2TIMAdvancedMsgListener -> onRecvMessageRevoked callback.
  • This API is available for all group types, including audio-video groups (AVChatRoom) and community groups, in 7.4 and later versions.
  • In one-to-one chats, only the sender can recall their own messages through this API.
  • In group chats, not only the sender can recall their own message, but administrators or group owners can also recall messages sent by other group members through this API.

◆ modifyMessage:completion:()

- (void) modifyMessage: (V2TIMMessage *)  msg
completion: (V2TIMMessageModifyCompletion completion 

5.5 Modify message

Attention
Notes:
  • If the message is modified successfully, both the user and the peer user (C2C) or group member (Group) will receive the onRecvMessageModified callback.
  • If the message has been modified by others during the process of modifying the message, the completion will return ERR_SDK_MSG_MODIFY_CONFLICT error.
  • Completion returns the latest message object regardless of whether the message is modified successfully or failed.

◆ deleteMessageFromLocalStorage:succ:fail:()

- (void) deleteMessageFromLocalStorage: (V2TIMMessage *)  msg
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.6 Delete a message from local storage

Attention
Messages can only be deleted locally. After a message is deleted, the SDK marks the message as deleted locally, and the message can no longer be pulled via getHistoryMessage. However, after the app is uninstalled and reinstalled, the local delete marker of the message will get lost, and the message can still be pulled via getHistoryMessage.

◆ deleteMessages:succ:fail:()

- (void) deleteMessages: (NSArray< V2TIMMessage * > *)  msgList
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.7 Delete messages from local storage and the cloud

Attention
In addition to deleting messages from the local storage (deleteMessageFromLocalStorage), this API simultaneously deletes messages from the cloud, and the deleted messages cannot be recovered. Please note that:
  • Up to 50 messages can be deleted at a time.
  • The messages to be deleted at a time must belong to the same conversation.
  • This API can be called only once per second.
  • If the account has pulled these messages from other devices, the messages will still be stored on those devices after this API is called to delete them. That is, the operation of message deletion cannot be synchronized across multiple devices.

◆ clearC2CHistoryMessage:succ:fail:()

- (void) clearC2CHistoryMessage: (NSString *)  userID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.8 Clear chat history with a user from local storage and the cloud (without deleting the conversation)

Supported only in 5.4.666 and later versions.

Attention
Notes:
  • When messages in a conversation are deleted from local storage, they are deleted simultaneously from the server.

◆ clearGroupHistoryMessage:succ:fail:()

- (void) clearGroupHistoryMessage: (NSString *)  groupID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.9 Clear chat history of a group from local storage and the cloud (without deleting the conversation)

Supported only in 5.4.666 and later versions.

Attention
Notes:
  • When messages in a conversation are deleted from local storage, they are also deleted from the server.

◆ insertGroupMessageToLocalStorage:to:sender:succ:fail:()

- (NSString *) insertGroupMessageToLocalStorage: (V2TIMMessage *)  msg
to: (NSString *)  groupID
sender: (NSString *)  sender
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.10 Add a message to the group message list

This API is mainly used to meet the requirement of inserting informative messages, such as "you have exited the group", into a group chat conversation. Such messages need to be displayed in the chat interface but do not need to be sent to others. Messages that need to be displayed in the chat interface but do not need to be sent to others. Therefore, insertGroupMessageToLocalStorage() is equivalent to a sendMessage() API whose network sending capability is disabled.

Returns
msgID Unique ID of a message
Attention
Messages saved via this API are saved only to the local storage and will get lost after the app is uninstalled.

◆ insertC2CMessageToLocalStorage:to:sender:succ:fail:()

- (NSString *) insertC2CMessageToLocalStorage: (V2TIMMessage *)  msg
to: (NSString *)  userID
sender: (NSString *)  sender
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.11 Insert a message in a one-to-one chat

This API is mainly used to meet the requirement of inserting informative messages, such as "you have exited the group", into a one-to-one chat conversation. Such messages need to be displayed in the chat interface but do not need to be sent to the peer party. Messages that need to be displayed in the chat interface but do not need to be sent to others. Therefore, insertC2CMessageToLocalStorage() is equivalent to a sendMessage() API whose network sending capability is disabled.

Returns
msgID Unique ID of a message
Attention
Messages saved via this API are saved only to the local storage and will get lost after the app is uninstalled.

◆ findMessages:succ:fail:()

- (void) findMessages: (NSArray< NSString * > *)  messageIDList
succ: (V2TIMMessageListSucc succ
fail: (V2TIMFail)  fail 

5.12 Query local messages in a specified conversation by messageID

Parameters
messageIDListMessage ID list

◆ searchLocalMessages:succ:fail:()

- (void) searchLocalMessages: (V2TIMMessageSearchParam *)  param
succ: (V2TIMSearchMessageListSucc succ
fail: (V2TIMFail)  fail 

5.13 Search for local messages (supported only in 5.4.666 and later versions and need to buy Flagship Edition)

Parameters
searchParamMessage search parameter. For details, see the definition of V2TIMMessageSearchParam.

◆ searchCloudMessages:succ:fail:()

- (void) searchCloudMessages: (V2TIMMessageSearchParam *)  param
succ: (V2TIMSearchMessageListSucc succ
fail: (V2TIMFail)  fail 

5.14 Search for cloud messages (supported only in 7.3 and later versions)

Parameters
searchParamMessage search parameter. For details, see the definition of V2TIMMessageSearchParam.
Attention

◆ sendMessageReadReceipts:succ:fail:()

- (void) sendMessageReadReceipts: (NSArray< V2TIMMessage * > *)  messageList
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.15 Send read receipts to the message sender for message which have been received(Supported only in 6.1 and later versions and need to buy Flagship Edition)

Attention
Notes:
  • To send a read receipt to a group message, you need to go to the console and turn on the corresponding switch.
  • After the API is called successfully, the conversation unread count will not change, and the message sender will receive the onRecvMessageReadReceipts callback, which will carry the latest read information of the message.

◆ getMessageReadReceipts:succ:fail:()

- (void) getMessageReadReceipts: (NSArray< V2TIMMessage * > *)  messageList
succ: (V2TIMMessageReadReceiptsSucc succ
fail: (V2TIMFail)  fail 

5.16 Get read receipts for messages which have been sent by myself(Supported only in 6.1 and later versions and need to buy Flagship Edition)

Attention
Notes:
  • To obtain the read receipt of group message, you need to go to the console and turn on the corresponding switch.
  • The messages in messageList must be in the same conversation.

◆ getGroupMessageReadMemberList:filter:nextSeq:count:succ:fail:()

- (void) getGroupMessageReadMemberList: (V2TIMMessage *)  message
filter: (V2TIMGroupMessageReadMembersFilter filter
nextSeq: (uint64_t)  nextSeq
count: (uint32_t)  count
succ: (V2TIMGroupMessageReadMemberListSucc succ
fail: (V2TIMFail)  fail 

5.17 Get group members profile who have read ths message.(Supported only in 6.1 and later versions and need to buy Flagship Edition)

Parameters
messagegroup message
filterSpecify the group message read members type.
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 read members pulled per page. maximum support 100.
Attention
Notes:
  • Please go to the console and turn on the corresponding switch before using this feature.

◆ setMessageExtensions:extensions:succ:fail:()

- (void) setMessageExtensions: (V2TIMMessage *)  message
extensions: (NSArray< V2TIMMessageExtension * > *)  extensions
succ: (V2TIMMessageExtensionsSetSucc succ
fail: (V2TIMFail)  fail 

5.18 Set message extensions (supported only in 6.7 and later versions)

Parameters
messageThe target message must be sent successfully and its supportMessageExtension field must be set to YES before sending. In addition, AVChatRoom message do not support this feature.
extensionsThe existing message extensions will be updated, and non-existing message extensions will be added directly.
Attention
  • You need to buy Flagship Edition to use this feature. And you need to go to the IM console to enable this feature.
  • The extension key supports a maximum of 100 bytes, the extension value supports a maximum of 1KB, a maximum of 20 extensions can be set at a time, and a maximum of 300 extensions can be set for a single message.
  • When multiple users set or delete the same extension key at the same time, only the first user can execute it successfully, and other users will receive the 23001 error code and the newest extension information. A retry operation can be invoked after receiveing the newest information.
  • We strongly recommend that different users set different extension keys, so that conflict will not appear in most scenarios. For example, you can use your userID as an extension key for voting, solitaire, and questionnaires.

◆ getMessageExtensions:succ:fail:()

- (void) getMessageExtensions: (V2TIMMessage *)  message
succ: (V2TIMMessageExtensionsGetSucc succ
fail: (V2TIMFail)  fail 

5.19 Get message extensions (supported only in 6.7 and later versions)

◆ deleteMessageExtensions:keys:succ:fail:()

- (void) deleteMessageExtensions: (V2TIMMessage *)  message
keys: (NSArray< NSString * > *)  keys
succ: (V2TIMMessageExtensionsDeleteSucc succ
fail: (V2TIMFail)  fail 

5.20 Delete message extensions (supported only in 6.7 and later versions)

Parameters
keysMessage extension key list, A maximum of 20 message extensions can be deleted at a time , if set to nil , it means to delete all extensions of the message.
Attention
  • When multiple users set or delete the same extension key at the same time, only the first user can execute it successfully, and other users will receive the 23001 error code and the newest extension information. A retry operation can be invoked after receiveing the newest information.

◆ addMessageReaction:reactionID:succ:fail:()

- (void) addMessageReaction: (V2TIMMessage *)  message
reactionID: (NSString *)  reactionID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.21 Add message reaction (can be used for emoji response) (supported only in 7.4 and later versions)

Emoji response function refers to the interaction response to a message through emoji symbols. We can see the number of responses and the list of responders for each emoji.

Currently, there are two common styles of message response display:

Style one:

-------------------------—

| lucy, happy birthday! |

-------------------------—

| 😄 1 💐 2 👍🏻 10 |

-------------------------—

Style two:

------------------------------------------------------—

| lucy, happy birthday! |

------------------------------------------------------—

| 😁 bob 💐olivia 🎂david |

| 👍🏻 denny、james、lucy、linda、thomas and other 10 people |

-------------------------------------------------------—

When the user clicks on an emoji, it will jump to the emoji response detail interface:

| 😄 | 💐 | 👍🏻 |

| bob | olivia | lucy |

| ... | ... | denny |

| ... | ... | ... |

Users can paginate fetching user profile based on a specific emoji.

You can implement emoji response capabilities based on SDK API:

1、Call addMessageReaction interface to add an emoji to a message. After adding successfully, the current operating user will be stored under the emoji.

2、Call removeMessageReaction interface to delete the added emoji. After deleting successfully, the current operating user will no longer be stored under the emoji.

3、Call getMessageReactions interface to batch fetch the emoji list of multiple messages. Each emoji contains the total number of current users and the first N (default 10) user profiles.

4、Call getAllUserListOfMessageReaction interface to paginate fetching the full list of user profiles using the message emoji.

5、Listen to the onRecvMessageReactionsChanged callback to perceive the change of user profile of the emoji. The callback will carry the latest user profile of the emoji (including the total number of users and the first N user profiles).

Parameters
reactionIDMessage reaction ID, in the emoji reply scenario, reactionID is the emojiID, a single message supports up to 10 reactions, and a single reaction supports up to 100 users.
Attention
  • You need to buy Flagship Edition to use this feature.
  • If the total count of reactions in a single message exceeds the maximum limit, the interface will report ERR_SVR_MSG_REACTION_COUNT_LIMIT error.
  • If the total count of users in a single reaction exceeds the maximum limit, the interface will report ERR_SVR_MSG_REACTION_USER_COUNT_LIMIT error.
  • If the reaction already contains the current operating user, the interface will report ERR_SVR_MSG_REACTION_ALREADY_CONTAIN_USER error.

◆ removeMessageReaction:reactionID:succ:fail:()

- (void) removeMessageReaction: (V2TIMMessage *)  message
reactionID: (NSString *)  reactionID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.22 Remove message reaction (supported only in 7.4 and later versions)

Attention
  • You need to buy Flagship Edition to use this feature.
  • If the reaction does not exist, the interface will report ERR_SVR_MSG_REACTION_NOT_EXISTS error.
  • If the reaction does not contain the current user, the interface will report ERR_SVR_MSG_REACTION_NOT_CONTAIN_USER error.

◆ getMessageReactions:maxUserCountPerReaction:succ:fail:()

- (void) getMessageReactions: (NSArray< V2TIMMessage * > *)  messageList
maxUserCountPerReaction: (uint32_t)  maxUserCountPerReaction
succ: (V2TIMGetMessageReactionsSucc succ
fail: (V2TIMFail)  fail 

5.23 Get message reactions (supported only in 7.4 and later versions)

Parameters
messageListMessage list, supports up to 20 messages at a time, messages must belong to the same conversation.
maxUserCountPerReactionThe value range is 【0,10】. Every reaction only supports returning the first 10 user profile at most. If you need more user profile, you can call the getAllUserListOfMessageReaction interface to pull in pages.
Attention
  • You need to buy Flagship Edition to use this feature.

◆ getAllUserListOfMessageReaction:reactionID:nextSeq:count:succ:fail:()

- (void) getAllUserListOfMessageReaction: (V2TIMMessage *)  message
reactionID: (NSString *)  reactionID
nextSeq: (uint32_t)  nextSeq
count: (uint32_t)  count
succ: (V2TIMGetMessageReactionUserListSucc succ
fail: (V2TIMFail)  fail 

5.24 Get all user list of message reaction (supported only in 7.4 and later versions)

Parameters
messageMessage object
reactionIDMessage reaction ID
nextSeqThe next pulling-by-page cursor, pass 0 for the first time, and pass the nextSeq returned by succ for subsequent pagination.
countThe maximum count of users fetched per page, up to 100.
Attention
  • You need to buy Flagship Edition to use this feature.

◆ translateText:sourceLanguage:targetLanguage:completion:()

- (void) translateText: (NSArray< NSString * > *)  sourceTextList
sourceLanguage: (NSString *)  source
targetLanguage: (NSString *)  target
completion: (void(^)(int code, NSString *desc, NSDictionary< NSString *, NSString * > *result))  callback 

5.25 Translate text message.

Parameters
sourceTextListTexts to be translated.
sourceSource language. You can pass the specific language or "auto". "auto" means identifying the source language automatically. If you set it to nil, "auto" will be filled as default.
targetTarget language. Multi languages are supported, like: English-"en", Simplified Chinese-"zh", French-"fr", German-"ge" and so on. For more languages, please refer to this documentation: Language support.
callbackTranslated result callback. The key represents the source text and value represents target text.

◆ markC2CMessageAsRead:succ:fail:()

- (void) markC2CMessageAsRead: (NSString *)  userID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.26 Mark one-to-one messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)

Attention
Notes:
  • After the API is successfully called, your unread count will be cleared to 0, and the peer user will receive the onRecvC2CReadReceipt callback, which will carry the time marked conversation read.
  • If the userID is nil, all one-to-one messages wil be marked as read. More importantly, it only supported in 5.8 and later versions.

◆ markGroupMessageAsRead:succ:fail:()

- (void) markGroupMessageAsRead: (NSString *)  groupID
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.27 Mark group messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)

Attention
Notes:
  • After the API is successfully called, your unread count will be cleared to 0.
  • If the groupID is nil, all group messages wil be marked as read. More importantly, it only supported in 5.8 and later versions.

◆ markAllMessageAsRead:fail:()

- (void) markAllMessageAsRead: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

5.28 Mark all messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)

Field Documentation

◆ kImSDK_MesssageAtALL

- (NSString* const) kImSDK_MesssageAtALL
protected

A constant string indicateds @all when filled in createTextAtMessage API.