Chat SDK for Android v1.2.1
agora java chat SDK
|
Public Member Functions | |
void | sendMessage (final ChatMessage msg) |
void | ackConversationRead (String conversationId) throws ChatException |
void | ackMessageRead (String to, String messageId) throws ChatException |
void | ackGroupMessageRead (String to, String messageId, String ext) throws ChatException |
void | recallMessage (ChatMessage message) throws ChatException |
void | asyncRecallMessage (final ChatMessage message, final CallBack callback) |
ChatMessage | getMessage (String messageId) |
Conversation | getConversation (String id) |
Conversation | getConversation (String id, ConversationType type) |
Conversation | getConversation (String username, ConversationType type, boolean createIfNotExists) |
Conversation | getConversation (String username, ConversationType type, boolean createIfNotExists, boolean isChatThread) |
void | markAllConversationsAsRead () |
int | getUnreadMessageCount () |
void | saveMessage (ChatMessage message) |
boolean | updateMessage (ChatMessage message) |
void | asyncModifyMessage (String messageId, MessageBody messageBodyModified, final ValueCallBack< ChatMessage > callBack) |
void | downloadAttachment (final ChatMessage msg) |
void | downloadThumbnail (final ChatMessage msg) |
void | downloadAndParseCombineMessage (ChatMessage message, ValueCallBack< List< ChatMessage > > callback) |
synchronized void | importMessages (List< ChatMessage > msgs) |
List< Conversation > | getConversationsByType (ConversationType type) |
Map< String, Conversation > | getAllConversations () |
List< Conversation > | getAllConversationsBySort () |
Map< String, Conversation > | fetchConversationsFromServer () throws ChatException |
void | asyncFetchConversationsFromServer (final ValueCallBack< Map< String, Conversation > > callBack) |
void | asyncFetchConversationsFromServer (int pageNum, int pageSize, final ValueCallBack< Map< String, Conversation > > callBack) |
void | asyncFetchPinnedConversationsFromServer (final int limit, final String cursor, final ValueCallBack< CursorResult< Conversation > > callback) |
void | asyncFetchConversationsFromServer (final int limit, final String cursor, final ValueCallBack< CursorResult< Conversation > > callback) |
void | asyncPinConversation (final String conversationId, boolean isPinned, final CallBack callback) |
void | loadAllConversations () |
boolean | deleteConversation (String username, boolean deleteMessages) |
void | deleteConversationFromServer (String username, ConversationType type, boolean isDeleteServerMessages, CallBack deleteCallBack) |
void | addMessageListener (MessageListener listener) |
void | removeMessageListener (MessageListener listener) |
void | addConversationListener (ConversationListener listener) |
void | removeConversationListener (ConversationListener listener) |
void | setVoiceMessageListened (ChatMessage message) |
boolean | updateParticipant (String from, String changeTo) |
CursorResult< GroupReadAck > | fetchGroupReadAcks (String msgId, int pageSize, String startAckId) throws ChatException |
void | asyncFetchGroupReadAcks (final String msgId, final int pageSize, final String startAckId, final ValueCallBack< CursorResult< GroupReadAck > > callBack) |
CursorResult< ChatMessage > | fetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId) throws ChatException |
CursorResult< ChatMessage > | fetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId, Conversation.SearchDirection direction) throws ChatException |
void | asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final ValueCallBack< CursorResult< ChatMessage > > callBack) |
void | asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final Conversation.SearchDirection direction, final ValueCallBack< CursorResult< ChatMessage > > callBack) |
void | asyncFetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String cursor, FetchMessageOption option, final ValueCallBack< CursorResult< ChatMessage > > callBack) |
List< ChatMessage > | searchMsgFromDB (Type type, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction) |
List< ChatMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction) |
void | deleteMessagesBeforeTimestamp (long timeStamp, CallBack callback) |
void | asyncReportMessage (String msgId, String tag, String reportReason, CallBack callBack) |
void | reportMessage (String msgId, String tag, String reportReason) throws ChatException |
void | fetchSupportLanguages (ValueCallBack< List< Language > > callBack) |
void | translateMessage (ChatMessage message, List< String > languages, ValueCallBack< ChatMessage > callBack) |
void | addReaction (final String messageId, final String reaction) throws ChatException |
void | asyncAddReaction (final String messageId, final String reaction, final CallBack callback) |
void | removeReaction (final String messageId, final String reaction) throws ChatException |
void | asyncRemoveReaction (final String messageId, final String reaction, final CallBack callback) |
Map< String, List< MessageReaction > > | getReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId) throws ChatException |
void | asyncGetReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId, final ValueCallBack< Map< String, List< MessageReaction > > > callback) |
CursorResult< MessageReaction > | getReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize) throws ChatException |
void | asyncGetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize, final ValueCallBack< CursorResult< MessageReaction > > callback) |
Protected Member Functions | |
void | removeMessagesFromServer (String conversationId, ConversationType type, List< String > msgIdList, CallBack callBack) |
void | removeMessagesFromServer (String conversationId, ConversationType type, long beforeTimeStamp, CallBack callBack) |
The chat manager class, responsible for sending and receiving messages, managing conversations (including loading and deleting conversations), and downloading attachments.
The sample code for sending a text message is as follows:
void io.agora.chat.ChatManager.ackConversationRead | ( | String | conversationId | ) | throws ChatException |
Sends the conversation read receipt to the server.
This method is only for one-to-one chat conversations.
This method will inform the sever to set the unread message count of the conversation to 0
. The message sender will receive the ConversationListener#onConversationRead(String, String) callback. The message recipient that has logged in to multiple devices, will also receive the callback.
If you want to send a read receipt for a group message, call ackGroupMessageRead(String, String, String).
conversationId | The conversation ID. |
ChatException | The possible exceptions are as follows: Error#USER_NOT_LOGIN, Error#SERVER_NOT_REACHABLE, and Error#MESSAGE_INVALID. See Error. |
void io.agora.chat.ChatManager.ackGroupMessageRead | ( | String | to, |
String | messageId, | ||
String | ext | ||
) | throws ChatException |
Sends the read receipt for a group message to the server.
Note
You can only call this method after setting ChatOptions#setRequireAck(boolean) and ChatMessage#setIsNeedGroupAck(boolean) to true
.
To send the read recipient for a one-to-one chat message to the server, call ackMessageRead(String, String).
To send the conversation read receipt to the server, call ackConversationRead(String).
to | The conversation ID. |
messageId | The message ID. |
ext | The extension information, which is a custom keyword that specifies a custom action or command. |
ChatException | A description of the exception, see Error. |
void io.agora.chat.ChatManager.ackMessageRead | ( | String | to, |
String | messageId | ||
) | throws ChatException |
Sends the read receipt for a message to the server.
Note
This method applies to one-to-one chats only.
This method only takes effect if you set ChatOptions#setRequireAck(boolean) as true
.
To send the read receipt for a group message, call ackGroupMessageRead(String, String, String).
We recommend that you call ackConversationRead(String) when opening the chat page, and call this method in other cases to reduce the number of method calls.
to | The message for which the read receipt is to be sent. |
messageId | The message ID. |
ChatException | A description of the exception, see Error. |
void io.agora.chat.ChatManager.addConversationListener | ( | ConversationListener | listener | ) |
Adds the conversation listener.
After a conversation listener is added, you can listen for conversation changes and conversation read receipts.
You can call the removeConversationListener(ConversationListener) method to remove the conversation listener when it is not required.
listener | The conversation listener to add. See ConversationListener. |
void io.agora.chat.ChatManager.addMessageListener | ( | MessageListener | listener | ) |
Adds the message listener.
After a message listener is added, you can listen for new messages when they arrive.
You can call removeMessageListener(MessageListener) to remove the message listener when it is not required.
listener | The message listener to add. See MessageListener. |
void io.agora.chat.ChatManager.addReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws ChatException |
Adds a Reaction.
This is a synchronous method.
messageId | The message ID. |
reaction | The Reaction content. |
ChatException | A description of the exception. See Error. |
void io.agora.chat.ChatManager.asyncAddReaction | ( | final String | messageId, |
final String | reaction, | ||
final CallBack | callback | ||
) |
Adds a Reaction.
This is an asynchronous method.
messageId | The message ID. |
reaction | The message Reaction to add. |
callback | The result callback which contains the error information if the method fails. See CallBack. |
void io.agora.chat.ChatManager.asyncFetchConversationsFromServer | ( | final int | limit, |
final String | cursor, | ||
final ValueCallBack< CursorResult< Conversation > > | callback | ||
) |
Gets the list of conversations from the server with pagination.
The SDK retrieves the list of conversations in the reverse chronological order of their active time (generally the timestamp of the last message).
If there is no message in the conversation, the SDK retrieves the list of conversations in the reverse chronological order of their creation time.
limit | The number of conversations that you expect to get on each page. The value range is [1,50]. |
cursor | The position from which to start to get data. If you pass in null or an empty string (""), the SDK retrieves conversations from the latest active one. |
callback | The query result CursorResult, including the cursor for getting data next time and the conversation list. For the last page, the return value of cursor is an empty string. |
void io.agora.chat.ChatManager.asyncFetchConversationsFromServer | ( | final ValueCallBack< Map< String, Conversation > > | callBack | ) |
Gets the conversation list from the server.
This is an asynchronous method.
void io.agora.chat.ChatManager.asyncFetchConversationsFromServer | ( | int | pageNum, |
int | pageSize, | ||
final ValueCallBack< Map< String, Conversation > > | callBack | ||
) |
Gets the conversation list from the server with pagination.
This is an asynchronous method.
pageNum | The current page number, starting from 1. |
pageSize | The number of conversations to get on each page. The value range is [1,20]. |
void io.agora.chat.ChatManager.asyncFetchGroupReadAcks | ( | final String | msgId, |
final int | pageSize, | ||
final String | startAckId, | ||
final ValueCallBack< CursorResult< GroupReadAck > > | callBack | ||
) |
Uses the pagination to get read receipts for the group message from the server.
To send a read receipt for a group message, you can call ackGroupMessageRead(String, String, String).
This is an asynchronous method.
msgId | The message ID. |
pageSize | The number of read receipts for the group message that you expect to get on each page. The value range is [1,50]. |
startAckId | The starting read receipt ID for query. After this parameter is set, the SDK retrieves read receipts, from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set as null or an empty string, the SDK retrieves read receipts, from the latest one, in the reverse chronological order of when the server receives them. |
callBack | The result callback:
|
void io.agora.chat.ChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final ConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final Conversation.SearchDirection | direction, | ||
final ValueCallBack< CursorResult< ChatMessage > > | callBack | ||
) |
Uses the pagination to get the messages of all types in the conversation from the server according to the message search direction.
This is an asynchronous method.
conversationId | The conversation ID.
|
type | The conversation type. See ConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as "null" or an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter.
|
direction | The message search direction. See Conversation.SearchDirection.
|
callBack | The result callback:
|
void io.agora.chat.ChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final ConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final ValueCallBack< CursorResult< ChatMessage > > | callBack | ||
) |
Uses the pagination to get the messages of all types in the conversation from the server.
This is an asynchronous method.
conversationId | The conversation ID.
|
type | The conversation type. See ConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set as "null" or an empty string, the SDK retrieves messages, starting from the latest one, in the reverse chronological order of when the server receives them. |
callBack | The result callback:
|
void io.agora.chat.ChatManager.asyncFetchHistoryMessages | ( | String | conversationId, |
ConversationType | type, | ||
int | pageSize, | ||
String | cursor, | ||
FetchMessageOption | option, | ||
final ValueCallBack< CursorResult< ChatMessage > > | callBack | ||
) |
/**
Uses the pagination to get the messages in the conversation from the server according to the message pulling parameter configuration class (FetchMessageOption
).
This is a asynchronous method.
conversationId | The conversation ID.
|
type | The conversation type. See ConversationType. |
pageSize | The number of messages you expect to get on each page. The value range is [1,50]. |
cursor | The cursor position from which to start querying data. |
option | The parameter configuration class for querying historical messages. See FetchMessageOption. |
callBack | The result callback:
|
void io.agora.chat.ChatManager.asyncFetchPinnedConversationsFromServer | ( | final int | limit, |
final String | cursor, | ||
final ValueCallBack< CursorResult< Conversation > > | callback | ||
) |
Get the list of pinned conversations from the server with pagination.
The SDK returns pinned conversations in the reverse chronological order of their pinning.
limit | The number of conversations that you expect to get on each page. The value range is [1,50]. |
cursor | The position from which to start getting data. If you pass in null or an empty string (""), the SDK retrieves the pinned conversations from the latest pinned one. |
callback | The query result CursorResult, including the cursor for getting data next time and the list of pinned conversations. For the last page, the return value of cursor is an empty string. |
void io.agora.chat.ChatManager.asyncGetReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize, | ||
final ValueCallBack< CursorResult< MessageReaction > > | callback | ||
) |
Gets the Reaction details.
This is an asynchronous method.
messageId | The message ID. |
reaction | The Reaction content. |
cursor | The cursor position from which to start querying data. |
pageSize | The number of Reactions you expect to get on each page. |
callback | The query result CursorResult, which contains the cursor for the next query and MessageReaction list (only the first data entry is used). |
void io.agora.chat.ChatManager.asyncGetReactionList | ( | final List< String > | messageIdList, |
final ChatMessage.ChatType | chatType, | ||
final String | groupId, | ||
final ValueCallBack< Map< String, List< MessageReaction > > > | callback | ||
) |
Gets the list of Reactions.
This is an asynchronous method.
messageIdList | The message ID. |
chatType | The conversation type. Only one-to-one chats (ChatMessage.ChatType#Chat and group chats (ChatMessage.ChatType#GroupChat) are allowed. |
groupId | The group ID, which is valid only for group chats. |
callback | The Reaction list under the specified message ID. The UserList of MessageReaction indicates the summary data, which only contains the information of the first three users. |
void io.agora.chat.ChatManager.asyncModifyMessage | ( | String | messageId, |
MessageBody | messageBodyModified, | ||
final ValueCallBack< ChatMessage > | callBack | ||
) |
Modifies a message.
After this method is called to modify a message, both the local message and the message on the server are modified.
This method can only modify a text message in one-to-one chats or group chats, but not in chat rooms.
Upon a message modification, the callback MessageListener#onMessageContentChanged(ChatMessage, String, long) will be received by the message recipient(s) and in multi-device login scenarios.
messageId | The ID of the message to modify. |
messageBodyModified | The modified message body. |
callBack | The message modification callback. A object of the ValueCallBack class. See ValueCallBack,contains the message modified. |
void io.agora.chat.ChatManager.asyncPinConversation | ( | final String | conversationId, |
boolean | isPinned, | ||
final CallBack | callback | ||
) |
Sets whether to pin a conversation.
conversationId | The conversation ID. |
isPinned | Whether to pin the conversation:
|
false
: No. The conversation is unpinned. callback | The callback for setting whether to pin the conversation. |
void io.agora.chat.ChatManager.asyncRecallMessage | ( | final ChatMessage | message, |
final CallBack | callback | ||
) |
void io.agora.chat.ChatManager.asyncRemoveReaction | ( | final String | messageId, |
final String | reaction, | ||
final CallBack | callback | ||
) |
Deletes a Reaction.
This is an asynchronous method.
messageId | The message ID. |
reaction | The Reaction to delete. |
callback | The result callback which contains the error information if the method fails. See CallBack. |
void io.agora.chat.ChatManager.asyncReportMessage | ( | String | msgId, |
String | tag, | ||
String | reportReason, | ||
CallBack | callBack | ||
) |
Reports an inappropriate message.
This is an asynchronous method.
msgId | The ID of the message to report. |
tag | The tag of the inappropriate message. You need to type a custom tag, like porn or ad . |
reportReason | The reporting reason. You need to type a specific reason. |
callBack | The result callback. See CallBack.
|
boolean io.agora.chat.ChatManager.deleteConversation | ( | String | username, |
boolean | deleteMessages | ||
) |
Deletes a conversation and its local messages from the local database.
username | The conversation ID. |
deleteMessages | Whether to delete the historical messages with the conversation.
|
true
: Yes.false
: No. void io.agora.chat.ChatManager.deleteConversationFromServer | ( | String | username, |
ConversationType | type, | ||
boolean | isDeleteServerMessages, | ||
CallBack | deleteCallBack | ||
) |
Deletes the specified conversation and its historical messages from the server.
This is an asynchronous method.
username | The conversation ID. |
type | The conversation type. See ConversationType. |
isDeleteServerMessages | Whether to delete the historical messages with the conversation.
|
deleteCallBack | The callback for the deletion of the conversation and its historical messages.
|
void io.agora.chat.ChatManager.deleteMessagesBeforeTimestamp | ( | long | timeStamp, |
CallBack | callback | ||
) |
Deletes local historical messages with a Unix timestamp before a specified one.
timeStamp | The starting Unix timestamp in the message for query. This unit is millisecond. |
callback | The result callback. See CallBack. |
void io.agora.chat.ChatManager.downloadAndParseCombineMessage | ( | ChatMessage | message, |
ValueCallBack< List< ChatMessage > > | callback | ||
) |
Downloads and parses the attachment of the combined message.
For a combined message, this method downloads and parses the attachment and returns the message list at the first call; for subsequent calls, there are two cases: 1.If the attachment already exits, this method directly parses it and returns the message list. 2.If the attachment does not exist, this method downloads it before parsing it and returning the message list.
message | The combined message to download and parse. |
callback | The completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object) and returns the parsed message list; If this call fails, calls ValueCallBack#onError(int, String). |
void io.agora.chat.ChatManager.downloadAttachment | ( | final ChatMessage | msg | ) |
Downloads the message attachment.
You can also call this method if the attachment fails to be downloaded automatically.
msg | The ID of the message with the attachment to be downloaded. |
void io.agora.chat.ChatManager.downloadThumbnail | ( | final ChatMessage | msg | ) |
Downloads the message thumbnail.
msg | The message with the thumbnail to be downloaded. Only the image messages and video messages have a thumbnail. |
Map< String, Conversation > io.agora.chat.ChatManager.fetchConversationsFromServer | ( | ) | throws ChatException |
Gets the conversation list from the server.
You can pull 10 conversations within 7 days by default (each conversation contains the latest historical message).
This is a synchronous method and blocks the current thread.
CursorResult< GroupReadAck > io.agora.chat.ChatManager.fetchGroupReadAcks | ( | String | msgId, |
int | pageSize, | ||
String | startAckId | ||
) | throws ChatException |
Uses the pagination to get read receipts for a group message from the server.
To send a read receipt for a group message, you can call ackGroupMessageRead(String, String, String).
This is a synchronous method and blocks the current thread.
msgId | The message ID. |
pageSize | The number of read receipts for the group message that you expect to get on each page. The value range is [1,50]. |
startAckId | The starting read receipt ID for query. After this parameter is set, the SDK retrieves read receipts, from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set as null or an empty string, the SDK retrieves read receipts, from the latest one, in the reverse chronological order of when the server receives them. |
ChatException | A description of the exception. See Error. |
CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages | ( | String | conversationId, |
ConversationType | type, | ||
int | pageSize, | ||
String | startMsgId | ||
) | throws ChatException |
Uses the pagination to get the messages of all types in the conversation from the server.
This is a synchronous method and blocks the current thread.
conversationId | The conversation ID.
|
type | The conversation type. See ConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set as null or an empty string, the SDK retrieves messages, starting from the latest one, in the reverse chronological order of when the server receives them. |
ChatException | A description of the exception. See Error. |
CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages | ( | String | conversationId, |
ConversationType | type, | ||
int | pageSize, | ||
String | startMsgId, | ||
Conversation.SearchDirection | direction | ||
) | throws ChatException |
Uses the pagination to get the messages of all types in the conversation from the server according to the message search direction.
This is a synchronous method and blocks the current thread.
conversationId | The conversation ID.
|
type | The conversation type. See ConversationType. |
pageSize | The number of messages you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as "null" or an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter.
|
direction | The message search direction. See Conversation.SearchDirection.
|
ChatException | A description of the exception. See Error. |
void io.agora.chat.ChatManager.fetchSupportLanguages | ( | ValueCallBack< List< Language > > | callBack | ) |
Gets all languages supported by the translation service.
callBack | The result callback. See CallBack.
|
Map< String, Conversation > io.agora.chat.ChatManager.getAllConversations | ( | ) |
Gets all local conversations.
Conversations will be first retrieved from the memory. If no conversation is found, the SDK retrieves from the local database.
List< Conversation > io.agora.chat.ChatManager.getAllConversationsBySort | ( | ) |
Gets all local conversations.
Pinned conversations are listed at the top of the list and followed by unpinned conversations.
The SDK returns conversations in the descending order of the timestamp of the latest message in them, with the pinned ones at the top of the list and followed by the unpinned ones.
Conversations will be first retrieved from the memory. If no conversation is found, the SDK retrieves from the local database.
Conversation io.agora.chat.ChatManager.getConversation | ( | String | id | ) |
Gets the conversation object by conversation ID.
The SDK will return null
if the conversation is not found.
id | The conversation ID. |
null
if the conversation is not found. Conversation io.agora.chat.ChatManager.getConversation | ( | String | id, |
ConversationType | type | ||
) |
Gets the conversation by conversation ID and type.
The SDK will return null
if the conversation is not found.
id | The conversation ID:
|
type | The conversation type. See ConversationType |
null
if the conversation is not found. Conversation io.agora.chat.ChatManager.getConversation | ( | String | username, |
ConversationType | type, | ||
boolean | createIfNotExists | ||
) |
Gets the conversation object by user ID or group ID and conversation type.
username | The conversation ID:
|
type | The conversation type. See ConversationType. |
createIfNotExists | Whether to create a conversation if the specified conversation is not found:
|
null
if the conversation is not found. Conversation io.agora.chat.ChatManager.getConversation | ( | String | username, |
ConversationType | type, | ||
boolean | createIfNotExists, | ||
boolean | isChatThread | ||
) |
Get conversation object by conversation id and conversation type.
If the conversation is not found, you can create a new object based on the value of CreateIFNotExists or an empty object.
username | The conversation ID.
|
type | The conversation type. See ConversationType. |
createIfNotExists | Whether to create a conversation if the specified conversation is not found:
|
isChatThread | Whether to search for the chat thread conversation.
|
null
if the conversation is not found. List< Conversation > io.agora.chat.ChatManager.getConversationsByType | ( | ConversationType | type | ) |
Gets the list of conversations by conversation type.
type | The conversation type. See ConversationType. |
ChatMessage io.agora.chat.ChatManager.getMessage | ( | String | messageId | ) |
Gets the message by message ID.
messageId | The message ID. |
null
if the message does not exist. CursorResult< MessageReaction > io.agora.chat.ChatManager.getReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize | ||
) | throws ChatException |
Gets the Reaction details.
This is a synchronous method.
messageId | The message ID. |
reaction | The Reaction content. |
cursor | The cursor position from which to start querying data. |
pageSize | The number of Reactions you expect to get on each page. |
null
, all data is obtained. ChatException | A description of the exception, see Error. |
Map< String, List< MessageReaction > > io.agora.chat.ChatManager.getReactionList | ( | final List< String > | messageIdList, |
final ChatMessage.ChatType | chatType, | ||
final String | groupId | ||
) | throws ChatException |
Gets the list of Reactions.
This is a synchronous method.
messageIdList | The message ID. |
chatType | The conversation type. Only the one-to-one chats (ChatMessage.ChatType#Chat and group chats (ChatMessage.ChatType#GroupChat) are allowed. |
groupId | The group ID, which is invalid only for group chats. |
UserList
of MessageReaction
indicates the summary data, which only contains the information of the first three users. ChatException | A description of the exception. See Error. |
int io.agora.chat.ChatManager.getUnreadMessageCount | ( | ) |
Gets the unread message count.
synchronized void io.agora.chat.ChatManager.importMessages | ( | List< ChatMessage > | msgs | ) |
Imports messages to the local database.
You can only import messages that you sent or received.
It is recommended that you import at most 1,000 messages each time.
msgs | The messages to import. |
void io.agora.chat.ChatManager.loadAllConversations | ( | ) |
Loads all conversations from the local database into the memory.
Generally, this method is called upon successful login to speed up the loading of the conversation list.
void io.agora.chat.ChatManager.markAllConversationsAsRead | ( | ) |
Marks all conversations as read.
This method is for the local conversations only.
void io.agora.chat.ChatManager.recallMessage | ( | ChatMessage | message | ) | throws ChatException |
Recalls the sent message.
If the recipient is offline when the message is delivered and recalled, the recipient only receives the callback MessageListener#onMessageRecalled instead of the message.
This is a synchronous method and blocks the current thread.
message | The message instance. |
ChatException | A description of the exception. See Error. |
void io.agora.chat.ChatManager.removeConversationListener | ( | ConversationListener | listener | ) |
Removes the conversation listener.
After adding a conversation listener with addConversationListener(ConversationListener), you can call this method to remove it when it is not required.
listener | The conversation listener to remove. |
void io.agora.chat.ChatManager.removeMessageListener | ( | MessageListener | listener | ) |
Removes the message listener.
After adding a message listener with addMessageListener(MessageListener), you can call this method to remove it when it is not required.
listener | The message listener to remove. |
|
protected |
Unidirectionally removes historical message by message ID from the server.
conversationId | The conversation ID. |
type | The conversation type. |
msgIdList | The list of IDs of messages to be removed. |
callBack | The result callback which contains the error information if the method fails. See CallBack. |
|
protected |
Unidirectionally removes historical message by timestamp from the server.
conversationId | The conversation ID. |
type | The conversation type. |
beforeTimeStamp | The UNIX timestamp in millisecond. Messages with a timestamp smaller than the specified one will be removed. |
callBack | The result callback which contains the error information if the method fails. See CallBack. |
void io.agora.chat.ChatManager.removeReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws ChatException |
Deletes a Reaction.
This is a synchronous method.
messageId | The message ID. |
reaction | The Reaction content to delete. |
ChatException | A description of the exception. See Error. |
void io.agora.chat.ChatManager.reportMessage | ( | String | msgId, |
String | tag, | ||
String | reportReason | ||
) | throws ChatException |
Reports an inappropriate message.
This is a synchronous method and blocks the current thread.
msgId | The ID of the inappropriate message. |
tag | The tag of the inappropriate message. You need to type a custom tag, like porn or ad . |
reportReason | The reporting reason. You need to type a specific reason. |
ChatException | A description of the exception. See Error. |
void io.agora.chat.ChatManager.saveMessage | ( | ChatMessage | message | ) |
Saves the message to the memory and local database.
The command messages (type: Type#CMD, message body: CmdMessageBody) are not saved locally.
message | The message to store. |
List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
Conversation.SearchDirection | direction | ||
) |
Retrieves messages with keywords in the conversation in the local database.
keywords | The keywords for query. |
timeStamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The user ID of the message sender in one-to-one chat or group chat. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation. |
direction | The message search direction. See Conversation.SearchDirection.
|
List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB | ( | Type | type, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
Conversation.SearchDirection | direction | ||
) |
Retrieves messages of a certain type in the conversation from the local database.
type | The message type. See Type. |
timeStamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The user ID of the message sender in one-to-one chat or group chat. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation. |
direction | The message search direction. See Conversation.SearchDirection.
|
void io.agora.chat.ChatManager.sendMessage | ( | final ChatMessage | msg | ) |
Sends a message。
For a voice or image message or a message with an attachment, the SDK will automatically upload the attachment.
You can determine whether to upload the attachment to the chat sever by setting ChatOptions#setAutoTransferMessageAttachments(boolean).
To listen for the message sending status, call ChatMessage#setMessageStatusCallback(CallBack).
msg | The message object to be sent. Make sure to set the param. |
void io.agora.chat.ChatManager.setVoiceMessageListened | ( | ChatMessage | message | ) |
Marks a voice message as listened.
message | The message object. |
void io.agora.chat.ChatManager.translateMessage | ( | ChatMessage | message, |
List< String > | languages, | ||
ValueCallBack< ChatMessage > | callBack | ||
) |
Translates a text message.
message | The message object for translation. |
languages | The list of target language codes. |
callBack | The result callback. See CallBack.
|
boolean io.agora.chat.ChatManager.updateMessage | ( | ChatMessage | message | ) |
Updates the local message.
This method updates the message in both the memory and the local database at the same time.
message | The message object to update. |
boolean io.agora.chat.ChatManager.updateParticipant | ( | String | from, |
String | changeTo | ||
) |
Changes the data of one contact in the local database to those of the other contact.
Note
from | The user ID of the original contact. |
changeTo | The user ID of the new contact. |
true
: Success.false
: Failure.