|
protected |
Callback definition on get history message list.
|
protected |
Callback definition on search history message.
|
protected |
Callback definition for file upload progress.
|
protected |
Callback definition for file download progress.
|
protected |
Callback definition for get message receive option.
|
protected |
Callback definition for get receipt for group message.
|
protected |
Callback definition for get read or unread members for group message.
|
protected |
Callback definition for message modification completed.
|
protected |
Callback definition for set message extensions.
|
protected |
Callback definition for get message extensions.
|
protected |
Callback definition for delete message extensions.
|
protected |
Enumeration definition of message status.
|
protected |
Enumeration definition of message element type.
|
protected |
|
protected |
|
protected |
Enumeration definition of group tip type.
|
protected |
Enumeration definition of change type to group information.
|
protected |
Enumeration definition of message pull type.
|
protected |
Enumeration definition of message receive option.
|
protected |
|
protected |
|
protected |
- (void) addAdvancedMsgListener: | (addAdvancedMsgListener(listener:)) | NS_SWIFT_NAME |
1.1 Add an event listener for advanced messages
- (void) removeAdvancedMsgListener: | (removeAdvancedMsgListener(listener:)) | NS_SWIFT_NAME |
1.2 Remove the event listener for advanced messages
- (V2TIMMessage *) createTextMessage: | (NSString *) | text |
2.1 Create a text message
- (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.
atUserList | List 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. |
- (V2TIMMessage *) createCustomMessage: | (NSData *) | data |
2.3 Create a custom message
- (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
desc | Custom message description information to be displayed in text during offline push |
extension | Extension field information during offline push |
- (V2TIMMessage *) createImageMessage: | (NSString *) | imagePath |
2.5 Create an image message (image size limit: 28 MB)
- (V2TIMMessage *) createSoundMessage: | (NSString *) | audioFilePath | |
duration: | (int) | duration | |
2.6 Create a voice message (voice size limit: 28 MB)
duration | Voice duration, in seconds |
- (V2TIMMessage *) createVideoMessage: | (NSString *) | videoFilePath | |
type: | (NSString *) | type | |
duration: | (int) | duration | |
snapshotPath: | (NSString *) | snapshotPath | |
2.7 Create a video message (video size limit: 100 MB)
type | Video type, such as mp4 and mov |
duration | Video duration, in seconds |
snapshotPath | Video cover image path |
- (V2TIMMessage *) createFileMessage: | (NSString *) | filePath | |
fileName: | (NSString *) | fileName | |
2.8 Create a file message (file size limit: 100 MB)
- (V2TIMMessage *) createLocationMessage: | (NSString *) | desc | |
longitude: | (double) | longitude | |
latitude: | (double) | latitude | |
2.9 Create a location message
- (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.
index | Emoji index |
data | Custom data |
- (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.
messageList | Message 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.) |
title | Source of the combined message, for example, "Chat History of Vinson and Lynx" and "xxx group chat history" |
abstractList | Combined 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. |
compatibleText | Combined 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. |
- (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.
message | Message object to be forwarded. The message status must be V2TIM_MSG_STATUS_SEND_SUCC. The message type cannot be V2TIMGroupTipsElem. |
- (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.
message | Original message object |
receiverList | Message receivers |
- (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.
message | Original message object |
atUserList | List 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. |
- (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)
message | Message object to be sent, which needs to be created via the corresponding message creation API |
receiver | Message recipient's userID. For a one-to-one message, you only need to specify this field. |
groupID | Target group ID For a group chat message, you only need to specify this field. |
priority | Message 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). |
onlineUserOnly | Whether 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). |
offlinePushInfo | Title and voice carried when the message pushing offline. |
- (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.
opt | There 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. |
- (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.
- (void) setGroupReceiveMessageOpt: | (NSString *) | groupID | |
opt: | (V2TIMReceiveMessageOpt) | opt | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
4.3 Set the group message receiving option
- (void) getC2CHistoryMessageList: | (NSString *) | userID | |
count: | (int) | count | |
lastMsg: | (V2TIMMessage *) | lastMsg | |
succ: | (V2TIMMessageListSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.1 Get historical one-to-one messages
count | Number 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. |
lastMsg | Start message for message pulling. If null is passed in, the newest message of the conversation will be considered as the start message. |
- (void) getGroupHistoryMessageList: | (NSString *) | groupID | |
count: | (int) | count | |
lastMsg: | (V2TIMMessage *) | lastMsg | |
succ: | (V2TIMMessageListSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.2 Get historical group messages
count | Number 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. |
lastMsg | Start message for message pulling. If null is passed in, the newest message of the conversation will be considered as the start message. |
- (void) getHistoryMessageList: | (V2TIMMessageListGetOption *) | option | |
succ: | (V2TIMMessageListSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.3 Get historical messages (advanced API)
option | Message pulling option, which can be set to pull older or newer messages from local storage or the cloud |
- (void) revokeMessage: | (V2TIMMessage *) | msg | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.4 Recall messages
- (void) modifyMessage: | (V2TIMMessage *) | msg | |
completion: | (V2TIMMessageModifyCompletion) | completion | |
5.5 Modify message
- (void) deleteMessageFromLocalStorage: | (V2TIMMessage *) | msg | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.6 Delete a message from local storage
- (void) deleteMessages: | (NSArray< V2TIMMessage * > *) | msgList | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.7 Delete messages from local storage and the cloud
- (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.
- (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.
- (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.
- (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.
- (void) findMessages: | (NSArray< NSString * > *) | messageIDList | |
succ: | (V2TIMMessageListSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.12 Query local messages in a specified conversation by messageID
messageIDList | Message ID list |
- (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)
searchParam | Message search parameter. For details, see the definition of V2TIMMessageSearchParam. |
- (void) sendMessageReadReceipts: | (NSArray< V2TIMMessage * > *) | messageList | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.14 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)
- (void) getMessageReadReceipts: | (NSArray< V2TIMMessage * > *) | messageList | |
succ: | (V2TIMMessageReadReceiptsSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.15 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)
- (void) getGroupMessageReadMemberList: | (V2TIMMessage *) | message | |
filter: | (V2TIMGroupMessageReadMembersFilter) | filter | |
nextSeq: | (uint64_t) | nextSeq | |
count: | (uint32_t) | count | |
succ: | (V2TIMGroupMessageReadMemberListSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.16 Get group members profile who have read ths message.(Supported only in 6.1 and later versions and need to buy Flagship Edition)
message | group message |
filter | Specify the group message read members type. |
nextSeq | Pulling-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. |
count | Number of read members pulled per page. maximum support 100. |
- (void) setMessageExtensions: | (V2TIMMessage *) | message | |
extensions: | (NSArray< V2TIMMessageExtension * > *) | extensions | |
succ: | (V2TIMMessageExtensionsSetSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.17 Set message extensions (supported only in 6.7 and later versions)
message | The 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. |
extensions | The existing message extensions will be updated, and non-existing message extensions will be added directly. |
- (void) getMessageExtensions: | (V2TIMMessage *) | message | |
succ: | (V2TIMMessageExtensionsGetSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.18 Get message extensions (supported only in 6.7 and later versions)
- (void) deleteMessageExtensions: | (V2TIMMessage *) | message | |
keys: | (NSArray< NSString * > *) | keys | |
succ: | (V2TIMMessageExtensionsDeleteSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.19 Delete message extensions (supported only in 6.7 and later versions)
keys | Message 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. |
- (void) translateText: | (NSArray< NSString * > *) | sourceTextList | |
sourceLanguage: | (NSString *) | source | |
targetLanguage: | (NSString *) | target | |
completion: | (void(^)(int code, NSString *desc, NSDictionary< NSString *, NSString * > *result)) | callback | |
5.20 Translate text message.
sourceTextList | Texts to be translated. |
source | Source 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. |
target | Target 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. |
callback | Translated result callback. The key represents the source text and value represents target text. |
- (void) markC2CMessageAsRead: | (NSString *) | userID | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.21 Mark one-to-one messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)
- (void) markGroupMessageAsRead: | (NSString *) | groupID | |
succ: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.22 Mark group messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)
- (void) markAllMessageAsRead: | (V2TIMSucc) | succ | |
fail: | (V2TIMFail) | fail | |
5.23 Mark all messages as read (It is deprecated and discouraged to call this function. Please call API CleanConversationUnreadMessageCount instead)
|
protected |
A constant string indicateds @all when filled in createTextAtMessage API.