Retrieve Recent Chat

Get Recent Chat#

To get the recent chat of a user or a group.

RecentChat recentChat = FlyCore.getRecentChatOf(JID);

Refer this doc to know more about RecentChat Class

ArgumentsTypeDescription
JIDStringjid of the user/group
caution

Will return a null object if a user never made a conversation with that user/group.

Get Recent Chat list#

To get the recent chat list call the below method.

ArrayList<RecentChat> recentChatList = FlyCore.getRecentChatList();
or
FlyCore.getRecentChatList((isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<RecentChat> recentChatList = (ArrayList<RecentChat>) data.get("data");
//update the UI
} else {
//Fetching recent chat list failed print throwable to find the exception details.
}
});
ArgumentDescriptionType
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
info

The method with callback runs on background thread and the one without callback didn't run on background thread

Get Recent Chat list of user by Pagination#

To get the recent chat list as pagination by providing the limit.

Initialization#

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

RecentChatListParams recentChatListParams = new RecentChatListParams();
recentChatListParams.setLimit(20);

Second, create a RecentChatListBuilder instance.

RecentChatListBuilder recentChatListBuilder = new RecentChatListBuilder(RECENT_CHAT_LIST_PARAM);
ArgumentTypeDescription
RECENT_CHAT_LIST_PARAMRecentChatListParamsInsatance of 'RecentChatListParams'

Load Initial Recent Chat List#

To fetch initial recent chat list of user, call the below method.

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

Load Next Set of Recent Chat List#

To fetch next set of data, call the below method.

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

Get Recent Chat list with archived chats#

To get the recent chat list including the arhived chat conversation call the below method.

ArrayList<RecentChat> recentChatList = FlyCore.getRecentChatListIncludingArchived();

Unread count#

if you want to get the unread count of chat messages, you can utilise the below method.

int unreadMessageCount = FlyMessenger.getUnreadMessagesCount();