Topic Based Chat

Topic based chat lets you to group the chat by topic. You can create the topic , send  all types of messages with topic information and thus you can receive the messages by topic.

Create Topic#

You can use the below given method to create a new topic.

ChatManager.createTopic(TOPIC_NAME,META_DATA, (isSuccess, throwable, data) -> {
});
ArgumentTypeDescription
TOPIC_NAMEStringName of the topic (cannot be null or empty)
META_DATAList<MetaData>META_DATA is an optional parameter to provide additional information about the topic. You can pass it as a List of MetaData Maximum Size is 3

Get Topics#

You can use the below given method to get the topics details.

ChatManager.getTopics(TOPIC_IDS, (isSuccess, throwable, data) -> {
if (isSuccess) {
Object result = ((JSONObject) data.get("data")).get("topics");
//handle success
} else {
// print throwable to find the exception details.
}
});
ArgumentTypeDescription
TOPIC_IDSArrayList<String>ArrayList of topic ids

Send Message#

To send the message to the user, use the below methods. Different messages such as text, image, audio, video & document type messages can be sent using the below methods.

Text message#

To send your text message, you need to pass the TextMessage object as an argument to the parameter in the sendTextMessage() method.

TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
textMessage.setReplyMessageId(REPLY_MESSAGE_ID); // Optional
textMessage.setMentionedUsersIds(MENTION_IDS); // Optional
textMessage.setMetaData(META_DATA); //Optional
textMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSTextMessageObject to hold the parameters of the text message
CALLBACKSendMessageCallbackcallback to observe the action status

Image message#

To send your image message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
fileMessageParams.setCaption(CAPTION); //Optional
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.IMAGE);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMentionedUsersIds(MENTION_IDS); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the image message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Image attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Image files.

Image message with url#

To send your image message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileName(FILE_NAME);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
fileMessageParams.setThumbImage(THUMB_IMAGE);
fileMessageParams.setCaption(CAPTION); //Optional
FileMessage sendMessageParams = new FileMessage();
sendMessageParams.setToId(TO_JID);
sendMessageParams.setMessageType(MessageType.IMAGE);
sendMessageParams.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
sendMessageParams.setMentionedUsersIds(MENTION_IDS); //Optional
sendMessageParams.setMetaData(META_DATA); //Optional
sendMessageParams.setTopicId(TOPIC_ID); //Optional
sendMessageParams.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(sendMessageParams, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the image message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Image attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Image files.

Video message#

To send your video message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
fileMessageParams.setCaption(CAPTION);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.VIDEO);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMentionedUsersIds(MENTION_IDS); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the video message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Video attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Video files.

Video message with url#

To send your video message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileName(FILE_NAME);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
fileMessageParams.setThumbImage(THUMB_IMAGE);
fileMessageParams.setDuration(DURATION);
fileMessageParams.setCaption(CAPTION); //Optional
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.VIDEO);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMentionedUsersIds(MENTION_IDS); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the video message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Video attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Video files.

Audio message#

To send your audio message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.AUDIO or MessageType.AUDIO_RECORDED);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the audio message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Audio attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Audio files.

Audio message with url#

To send your audio message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
fileMessageParams.setDuration(DURATION);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.AUDIO or MessageType.AUDIO_RECORDED);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the audio message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Audio attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Audio files.

Document message#

To send your document message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.DOCUMENT);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the document message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Document attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Document files.

Document message with url#

To send your document message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileName(FILE_NAME);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.DOCUMENT);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the document message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Document attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Document files.

Location message#

To send your location message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

LocationMessageParams locationMessageParams = new LocationMessageParams();
locationMessageParams.setLatitude(LATITUDE);
locationMessageParams.setLongitude(LONGITUDE);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.LOCATION);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setLocationMessage(locationMessageParams);
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the location message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Location attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Location message.

Contact message#

To send your contact message, you need to pass the FileMessage object as an argument to the parameter in the sendMediaFileMessage() method.

ContactMessageParams contactMessageParam = new ContactMessageParams();
contactMessageParam.setName(CONTACT_NAME);
contactMessageParam.setNumbers(CONTACT_NUMBERS);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.CONTACT);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setContactMessage(contactMessageParam);
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendMediaFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the contact message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Contact attachment feature unavailable for your plan then it will throw 403 exception.

FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future release. migrate to FlyMessenger.sendMediaFileMessage() method to send Contact message.

Meet message#

A meet message typically refers to a message or communication related to scheduling or planning a meeting. These messages can include information about the Scheduled date,time and meet link.

Create Meet link#

Before you send the meet message, you need to create the meet link using the createMeetLink method. Once the meet link has been created successfully, you can send the Meet message.

caution

If Group call feature is unavailable for your plan, then it will throw 403 exception

CallManager.createMeetLink((isSuccess, throwable, createMeetLinkData) -> {
if(isSuccess){
String meetlink = (String) createMeetLinkData.get("data");
}
});

To send your Meet message, you need to pass the MeetMessage object as an argument to the parameter in the sendMeetMessage() method.

MeetMessage meetMessage = new MeetMessage();
meetMessage.setToId(TO_JID);
meetMessage.setLink(LINK);
meetMessage.setScheduledDateTime(SCHEDULED_DATE_TIME);
meetMessage.setTitle(TITLE); //Optional
meetMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
meetMessage.setMentionedUsersIds(MENTION_IDS); //Optional
meetMessage.setMetaData(META_DATA); //Optional
meetMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendMeetMessage(meetMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSMeetMessageObject to hold the parameters of the meet message
CALLBACKSendMessageCallbackcallback to observe the action status

Send Reply message#

To send reply message to the original message, you need to pass the additional parameter original message-id in replyMessageId.TextMessage object as an argument to the parameter in the sendTextMessage() method.

TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
textMessage.setReplyMessageId(REPLY_MESSAGE_ID); // Optional
textMessage.setMentionedUsersIds(MENTION_IDS); // Optional
textMessage.setMetaData(META_DATA); //Optional
textMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSTextMessageObject to hold the parameters of the text message
CALLBACKSendMessageCallbackcallback to observe the action status

Receive Message#

To receive a Topic related message from another user you must implement the messageListener function. It’s a function that will be triggered whenever you receive a new message or related event in the chat.

fun onMessageReceived(ChatMessage message) {
}
info

To learn more on message listener callbacks, see the MessageEventsCallbacks.

Get Chats By TopicId#

To get all the list of TopicId related chats, send a request to the server as described below.

Initialization#

First, create a TopicChatListParams instance to set the topicId and recent chat list limits based on the inputs.

TopicChatListParams topicChatListParams = new TopicChatListParams();
topicChatListParams.setLimit(40);
topicChatListParams.setTopicId(TOPIC_ID);
ArgumentTypeDescription
LIMITIntNo of topic based chats will be fetched for each request default 40
TOPIC_IDStringParticular topic based chats will be fetched

Second, create a TopicChatListBuilder instance.

TopicChatListBuilder topicChatListBuilder = new TopicChatListBuilder(TOPIC_CHAT_LIST_PARAMS);
ArgumentTypeDescription
TOPIC_CHAT_LIST_PARAMSTopicChatListParamsInstance of 'TopicChatListParams'

Load Initial Topic Based Chat List#

To fetch initial Topic based recent chat list, call the below method.

topicChatListBuilder.loadTopicBasedChatList((isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<RecentChat> recentChatList = (ArrayList<RecentChat>) data.get("data");
} else {
// Fetch Topic Recent Chat List failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallback'FlyCallback' implemented as lambda expression

Load Next Set of Topic based Recent Chat List#

To fetch next set of topic based recent chat list, call the below method.

topicChatListBuilder.nextSetOfTopicBasedChatList((isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<RecentChat> recentChatList = (ArrayList<RecentChat>) data.get("data");
} else {
// Fetch Topic recent chat list failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallback'FlyCallback' implemented as lambda expression

Get messages#

To get the chat and media messages, use the below methods

Get Chat Messages#

Initialization#

First, create a FetchMessageListParams instance. Here, you need to set the message filter to determine the message order and the starting point of the message list in the chat view.

FetchMessageListParams messageListParams = new FetchMessageListParams();
messageListParams.setChatJid(JID);
messageListParams.setMessageId(MESSAGE_ID);
messageListParams.setMessageTime(MESSAGE_TIME);
messageListParams.setInclusive(true);
messageListParams.setAscendingOrder(true);
messageListParams.setLimit(50);
messageListParams.setTopicId(TOPIC_ID); //optional
ArgumentTypeDescription
JIDStringJid of the user/group
MESSAGE_IDStringMessage id of the starting point optional
MESSAGE_TIMEStringMessage time of the starting point optional
INCLUSIVEbooleanIf true starting point message will included in message list default false
ASCENDING_ORDERbooleanIf true message list will be returned ascendingOrder by message time default false
LIMITintNo of messages will be fetched for each request default 50
TOPIC_IDStringTopic Id to be fetched

Second, create a FetchMessageListQuery instance.

FetchMessageListQuery messageListQuery = new FetchMessageListQuery(MESSAGE_LIST_PARAM);
ArgumentTypeDescription
MESSAGE_LIST_PARAMFetchMessageListParamsInsatance of 'FetchMessageListParams'

Load Initial Messages#

To fetch initial conversations between you and a single chat user or group, call the below method.

messageListQuery.loadMessages((isSuccess, throwable, data) -> {
if (isSuccess) {
List<ChatMessage> messageList = (List<ChatMessage>) data.get("data");
} else {
// Fetch messages failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallback'FlyCallback' implemented as lambda expression

Load Previous Messages#

To fetch previous conversations between you and a single chat user or group, call the below method.

messageListQuery.loadPreviousMessages((isSuccess, throwable, data) -> {
if (isSuccess) {
List<ChatMessage> messageList = (List<ChatMessage>) data.get("data");
} else {
// Fetch messages failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallback'FlyCallback' implemented as lambda expression

Load Next Messages#

To fetch next conversations between you and a single chat user or group, call the below method.

messageListQuery.loadNextMessages((isSuccess, throwable, data) -> {
if (isSuccess) {
List<ChatMessage> messageList = (List<ChatMessage>) data.get("data");
} else {
// Fetch messages failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallback'FlyCallback' implemented as lambda expression

Check Previous Set of Messages Available or not#

To check previous set of conversations available or not, call the below method.

Boolean hasPreviousMessages = messageListQuery.hasPreviousMessages();

Check Next Set of Messages Available#

To check next set of conversations available or not, call the below method.

Boolean hasNextMessages = messageListQuery.hasNextMessages();

Check Message Fetching InProgress#

To check conversations fetching in progress or not, call the below method.

Boolean fetchingInProgress = messageListQuery.isFetchingInProgress();

Get media messages#

If you want to get the media messages for a user/group, you can utilise the below method.

List<ChatMessage> mediaMessages = ChatManager.getMediaMessages(JID);
ArgumentTypeDescription
JIDStringjid of the chat user
info

Above methods fetch media messages which are successfully sent and received.

caution

If media message feature unavailable for your plan then it will throw 403 exception.