Public Member Functions | |
abstract void | addAdvancedMsgListener (V2TIMAdvancedMsgListener listener) |
abstract void | removeAdvancedMsgListener (V2TIMAdvancedMsgListener listener) |
abstract V2TIMMessage | createTextMessage (String text) |
abstract V2TIMMessage | createTextAtMessage (String text, List< String > atUserList) |
abstract V2TIMMessage | createCustomMessage (byte[] data) |
abstract V2TIMMessage | createCustomMessage (byte[] data, String description, byte[] extension) |
abstract V2TIMMessage | createImageMessage (String imagePath) |
abstract V2TIMMessage | createSoundMessage (String soundPath, int duration) |
abstract V2TIMMessage | createVideoMessage (String videoFilePath, String type, int duration, String snapshotPath) |
abstract V2TIMMessage | createFileMessage (String filePath, String fileName) |
abstract V2TIMMessage | createLocationMessage (String desc, double longitude, double latitude) |
abstract V2TIMMessage | createFaceMessage (int index, byte[] data) |
abstract V2TIMMessage | createMergerMessage (List< V2TIMMessage > messageList, String title, List< String > abstractList, String compatibleText) |
abstract V2TIMMessage | createForwardMessage (V2TIMMessage message) |
abstract V2TIMMessage | createTargetedGroupMessage (V2TIMMessage message, List< String > receiverList) |
abstract V2TIMMessage | createAtSignedGroupMessage (V2TIMMessage message, List< String > atUserList) |
abstract String | sendMessage (V2TIMMessage message, String receiver, String groupID, int priority, boolean onlineUserOnly, V2TIMOfflinePushInfo offlinePushInfo, V2TIMSendCallback< V2TIMMessage > callback) |
abstract void | setC2CReceiveMessageOpt (List< String > userIDList, int opt, V2TIMCallback callback) |
abstract void | getC2CReceiveMessageOpt (List< String > userIDList, V2TIMValueCallback< List< V2TIMReceiveMessageOptInfo >> callback) |
abstract void | setGroupReceiveMessageOpt (String groupID, int opt, V2TIMCallback callback) |
abstract void | setAllReceiveMessageOpt (int opt, int startHour, int startMinute, int startSecond, long duration, V2TIMCallback callback) |
abstract void | setAllReceiveMessageOpt (int opt, long startTimeStamp, long duration, V2TIMCallback callback) |
abstract void | getAllReceiveMessageOpt (V2TIMValueCallback< V2TIMReceiveMessageOptInfo > callback) |
abstract void | getC2CHistoryMessageList (String userID, int count, V2TIMMessage lastMsg, V2TIMValueCallback< List< V2TIMMessage >> callback) |
abstract void | getGroupHistoryMessageList (String groupID, int count, V2TIMMessage lastMsg, V2TIMValueCallback< List< V2TIMMessage >> callback) |
abstract void | getHistoryMessageList (V2TIMMessageListGetOption option, V2TIMValueCallback< List< V2TIMMessage >> callback) |
abstract void | revokeMessage (V2TIMMessage msg, V2TIMCallback callback) |
abstract void | modifyMessage (V2TIMMessage msg, V2TIMCompleteCallback< V2TIMMessage > callback) |
abstract void | deleteMessageFromLocalStorage (V2TIMMessage msg, V2TIMCallback callback) |
abstract void | deleteMessages (List< V2TIMMessage > messages, V2TIMCallback callback) |
abstract void | clearC2CHistoryMessage (String userID, V2TIMCallback callback) |
abstract void | clearGroupHistoryMessage (String groupID, V2TIMCallback callback) |
abstract String | insertGroupMessageToLocalStorage (V2TIMMessage msg, String groupID, String sender, V2TIMValueCallback< V2TIMMessage > callback) |
abstract String | insertC2CMessageToLocalStorage (V2TIMMessage msg, String userID, String sender, V2TIMValueCallback< V2TIMMessage > callback) |
abstract void | findMessages (List< String > messageIDList, V2TIMValueCallback< List< V2TIMMessage >> callback) |
abstract void | searchLocalMessages (V2TIMMessageSearchParam searchParam, V2TIMValueCallback< V2TIMMessageSearchResult > callback) |
abstract void | searchCloudMessages (V2TIMMessageSearchParam searchParam, V2TIMValueCallback< V2TIMMessageSearchResult > callback) |
abstract void | sendMessageReadReceipts (List< V2TIMMessage > messageList, V2TIMCallback callback) |
abstract void | getMessageReadReceipts (List< V2TIMMessage > messageList, V2TIMValueCallback< List< V2TIMMessageReceipt >> callback) |
abstract void | getGroupMessageReadMemberList (V2TIMMessage message, int filter, long nextSeq, int count, V2TIMValueCallback< V2TIMGroupMessageReadMemberList > callback) |
abstract void | setMessageExtensions (V2TIMMessage message, List< V2TIMMessageExtension > extensions, V2TIMValueCallback< List< V2TIMMessageExtensionResult >> callback) |
abstract void | getMessageExtensions (V2TIMMessage message, V2TIMValueCallback< List< V2TIMMessageExtension >> callback) |
abstract void | deleteMessageExtensions (V2TIMMessage message, List< String > keys, V2TIMValueCallback< List< V2TIMMessageExtensionResult >> callback) |
abstract void | addMessageReaction (V2TIMMessage message, String reactionID, V2TIMCallback callback) |
abstract void | removeMessageReaction (V2TIMMessage message, String reactionID, V2TIMCallback callback) |
abstract void | getMessageReactions (List< V2TIMMessage > messageList, int maxUserCountPerReaction, V2TIMValueCallback< List< V2TIMMessageReactionResult >> callback) |
abstract void | getAllUserListOfMessageReaction (V2TIMMessage message, String reactionID, int nextSeq, int count, V2TIMValueCallback< V2TIMMessageReactionUserResult > callback) |
abstract void | translateText (List< String > sourceTextList, String sourceLanguage, String targetLanguage, V2TIMValueCallback< HashMap< String, String >> callback) |
abstract void | pinGroupMessage (String groupID, V2TIMMessage message, boolean isPinned, V2TIMCallback callback) |
abstract void | getPinnedGroupMessageList (String groupID, V2TIMValueCallback< List< V2TIMMessage >> callback) |
abstract void | markC2CMessageAsRead (String userID, V2TIMCallback callback) |
abstract void | markGroupMessageAsRead (String groupID, V2TIMCallback callback) |
abstract void | markAllMessageAsRead (V2TIMCallback callback) |
|
abstract |
1.1 Add an event listener for advanced messages
|
abstract |
1.2 Remove the event listener for advanced messages
|
abstract |
2.1 Create a text message
|
abstract |
2.2 Create a text message with the mentioning(@) feature
You can mention someone only in group chats.
atUserList | List of @ target users. To @all, please pass in the V2TIMGroupAtInfo.AT_ALL_TAG constant string. For example, if you want the current text message to @denny, @lucy, and @all, pass in ["denny","lucy",V2TIMGroupAtInfo.AT_ALL_TAG] for atUserList. |
|
abstract |
2.3 Create a custom message
|
abstract |
2.4 Create a custom message and set offline push information
description | Custom message description to be displayed for offline push |
extension | Extension field for offline push |
|
abstract |
2.5 Create an image message (image size limit: 28 MB)
|
abstract |
2.6 Create a voice message (voice size limit: 28 MB)
duration | Voice duration, in seconds |
|
abstract |
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 |
|
abstract |
2.8 Create a file message (file size limit: 100 MB)
|
abstract |
2.9 Create a location message
|
abstract |
2.10 Create an emoji message
The Chat 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 Chat SDK is only responsible for passing them through.
index | Emoji index |
data | Custom data |
|
abstract |
2.11 Create a combined message (supported only in 5.2.210 and later versions)
A typical combined message looks like this on the UI:
|Chat History of Vinson and Lynx | – title
|Vinson: When is the new version of SDK scheduled to go online? | – abstract1
|Lynx: Next Monday. The specific time depends on the system test result in these two days. | – abstract2
|Vinson: OK | – abstract3
The chat UI usually displays only the title and abstract of the combined message. 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 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 the user clicks the combined message 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 abstract list (supports up to 5 abstracts, each containing a maximum of 100 characters). You can use different abstract formats for different message types. For example, for a text message, the format can be "sender:text" format. For an image message, the format can be "sender:[image]". For a file message, the format can be in the "sender:[file]". |
compatibleText | Text to be displayed if the SDK version does not support combined messages. This parameter cannot be null. |
|
abstract |
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. |
|
abstract |
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 |
|
abstract |
2.14 Create a group message that mentions others(supported only in 7.0 and later versions)
If you need to send a group message with the mentioning (@) feature, use this API to create a message.
message | Original message object |
atUserList | List of @ target users. To @all, please pass in the V2TIMGroupAtInfo.AT_ALL_TAG constant string. For example, if you want the current message to @denny, @lucy, and @all, pass in @["denny", @"lucy", V2TIMGroupAtInfo.AT_ALL_TAG] for atUserList. |
|
abstract |
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 will not appear in the recipient's historical message list. This field is often used to implement less important notifications such as typing indicators. This field is not supported by audio-video groups (AVChatRoom). |
offlinePushInfo | Title and content for offline push |
|
abstract |
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. |
|
abstract |
4.2 Query the one-to-one message receiving option for specified users
Supported only in 5.3.425 and later versions.
|
abstract |
4.3 Set the group message receiving option
opt | There are five 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 group 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. V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT: messages will be received when the user is online, and no push notification will be received when the user is offline but except @ message. V2TIMMessage.V2TIM_NOT_RECEIVE_MESSAGE_EXCEPT_AT: only receive @ messages. |
|
abstract |
4.4 Set message receiving option for all conversations,supported only in 7.4 and later versions.
opt | There are two message receiving options for you to choose: V2TIMMessage.V2TIM_RECEIVE_MESSAGE:messages will be received when the user is online, and notifications will be received when the user is offline. 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.(you can use this to mute group chat notifications) |
startHour | (0 - 23) The starting hour of the muting duration |
startMinute | (0 - 59) The starting minute of the muting duration |
startSecond | (0 - 59) The starting second of the muting duration |
duration | (0 - 24*60*60) The muting duration in seconds |
|
abstract |
4.5 Set message receiving option for all conversations,supported only in 7.4 and later versions.
opt | There are two message receiving options for you to choose: V2TIMMessage.V2TIM_RECEIVE_MESSAGE:messages will be received when the user is online, and notifications will be received when the user is offline. 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.(you can use this to mute group chat notifications) |
startTimeStamp | The start time of muting, UTC timestamp, unit: second |
duration | The muting duration in seconds |
|
abstract |
4.6 Get the message receiving option for all conversations,supported only in 7.4 and later versions.
|
abstract |
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. |
|
abstract |
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. |
|
abstract |
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 |
|
abstract |
5.4 Recall messages
|
abstract |
5.5 Modify a message
|
abstract |
5.6 Delete a message from local storage
|
abstract |
5.7 Delete messages from local storage and the cloud
|
abstract |
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.
|
abstract |
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.
|
abstract |
5.10 Add a message to the group message list
This API is mainly used to insert informative messages in a group chat, such as "you have exited the group". Such messages are shown to the local user but not sent to others. In this sense, insertGroupMessageToLocalStorage() is sendMessage() API with the message delivery feature disabled.
|
abstract |
5.11 Insert a message in a one-to-one chat
This API is mainly used to insert informative messages in a one-to-one, such as "you have successfully sent the message". Such messages are shown to the local user but not sent to the remote user. In this sense, insertGroupMessageToLocalStorage() is sendMessage() API with the message delivery feature disabled.
|
abstract |
5.12 Query local messages in a specified conversation by messageID, including messages with the status V2TIM_MSG_STATUS_LOCAL_REVOKED (recalled) and V2TIM_MSG_STATUS_HAS_DELETED (deleted).
messageIDList | Message ID list |
|
abstract |
5.13 Search for local messages (supported only in Chat Premium 5.4.666 and later versions)
searchParam | Message search parameter. For details, see the definition of V2TIMMessageSearchParam. |
|
abstract |
5.14 Search for cloud messages (supported only in 7.3 and later versions)
searchParam | Message search parameter. For details, see the definition of V2TIMMessageSearchParam. |
|
abstract |
5.15 Send read receipts to the message sender (supported only in Chat Premium 6.1 and later versions)
|
abstract |
5.16 Get read receipts for messages sent (Supported only in Chat Premium 6.1 and later versions)
|
abstract |
5.17 Get group members who have read a group message (Supported only in Chat Premium 6.1 and later)
message | group message |
filter | Whether to get members who have or who have not read the message. Valid values: V2TIMMessage.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, V2TIMMessage.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD |
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 members (max 100) pulled per page. |
|
abstract |
5.18 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 true 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. |
|
abstract |
5.19 Get message extensions (supported only in 6.7 and later versions)
|
abstract |
5.20 Delete message extensions (supported only in 6.7 and later versions)
keys | Message extension key list. If this is null, it means to delete all extensions of the message. |
|
abstract |
5.21 Add a 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 |
| ... | ... | ... |
You can pull a list of users who responded with an emoji by page.
You can implement emoji response capabilities using the following SDK APIs:
1、Call addMessageReaction to add an emoji reaction to a message. If it succeeds, the current user will be added to the response list for that emoji.
2、Call removeMessageReaction to delete an added emoji reaction. If it succeeds, the current user will be removed from the response list for that emoji.
3、Call getMessageReactions to get the emoji reactions of multiple messages. The number of users who responded with each emoji and the information of the first N users (10 by default) will be returned.
4、Call getAllUserListOfMessageReaction to get the information of all users who responded with the emojis by page.
5、Listen to the onRecvMessageReactionsChanged callback to receive notifications about the change of emoji response. The callback will return the latest response information, including the total number of users who responded with each emoji and the information of the first N users.
reactionID | Message reaction ID. In the emoji response scenario, reactionID is the emojiID. A single message supports up to 10 reactions, and a single reaction supports up to 100 users. |
|
abstract |
5.22 Remove a message reaction (supported only in 7.4 and later versions)
|
abstract |
5.23 Get message reactions (supported only in 7.4 and later versions)
messageList | Message list, supports up to 20 messages at a time, which must belong to the same conversation. |
maxUserCountPerReaction | The 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. |
|
abstract |
5.24 Get a list of users who responded with an emoji (supported only in 7.4 and later versions)
message | Message object |
reactionID | Message reaction ID |
nextSeq | The pulling-by-page cursor. Pass 0 for the first time, and pass the nextSeq returned by succ for subsequent pagination. |
count | The maximum count of users fetched per page, up to 100. |
|
abstract |
5.25 Translate text message.
sourceTextList | Texts to be translated. |
sourceLanguage | 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. |
targetLanguage | 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. |
|
abstract |
5.26 Set the group message to the top(supported only in Chat Premium 7.9 and later versions)
groupID | Group ID |
isPinned | Whether to pin it to the top |
|
abstract |
5.27 Get the list of pinned group messages(supported only in Chat Premium 7.9 and later versions)
groupID | Group ID |
|
abstract |
5.28 Mark all messages of a one-to-one conversation as read (This is to be deprecated. Please call cleanConversationUnreadMessageCount instead.)
|
abstract |
5.29 Mark all messages of a group chat as read (This is to be deprecated. Please call cleanConversationUnreadMessageCount instead.)
|
abstract |
5.30 Mark all messages as read (This is to be deprecated. Please call cleanConversationUnreadMessageCount instead.)