Other chat features

Report User/Group Messages#

This feature is used to do report the user/group messages by selecting the message or user/group profile. If the user/group is reported by person to admin, the user's last 5 conversations or by selecting along with the selected message and previous 4 messages will be sent to the admin panel based on that chats availability. By using the below method person can achieve the User/Group report messages.

FlyCore.reportUserOrMessages(TO_USER_JID, CHAT_TYPE, SELECTED_MID, (isSuccess, throwable, data) -> {
if (isSuccess) {
// Report Success Response
} else {
// Report Failure Response
}
});

Note : In this method SELECTED_MID is optional argument. If person selected a message to report use this param other wise ignore the param.

ArgumentTypeDescription
TO_USER_JIDstringReport User Jid who needs to be reported
CHAT_TYPEstringUser chat type either single chat or group chat
SELECTED_MIDstringSelected Message ID

Handling Banned User/Group#

This feature is used to get the users/groups admin blocked status. So that you can check the user/group available status and communicate with them. If user/group blocked by admin then you will get notify the alert message.

Get Own user Admin Block Status#

This method is used to get the live status of own user profile blocked/unblocked by Admin status, so that you will be navigated to show stopper screen if profile blocked by admin.

@override
public void onAdminBlockedUser(String jid, boolean status) {
super.onAdminBlockedUser(jid, status)
// jid - own user profile jid, status - admin block/unblock status
// Write your logic here
// to show/hide showstopper screen, based on the admin block/unblock status
}
// To get the own user admin block/unblock status by using the below method while app is opening from background
FlyCore.getIsProfileBlockedByAdmin();

Get Other user/group Admin Block Status#

This method is used to get the live status of other user/group profile blocked/unblocked by Admin status, so that you will be notified the profile status.

@override
public void onAdminBlockedOtherUser(String jid, String type, boolean status) {
super.onAdminBlockedOtherUser(jid, type, status)
// jid - user/group profile jid, type - chat/groupchat, status - admin block/unblock status
// Write your logic here to handle the user/group communications
}

Send typing status#

You can able to send the typing/gone status to the users, so that they can aware of whether user is typing the message or not. if you want send the typing status for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the chat user
CHAT_TYPEChatTypeEnumchat type

While user starts typing the message in the input box of the chat window, call the below method to send the composing status, so that they can show a typing message in the header/recent chat.

ChatManager.sendTypingStatus(TO_JID, CHAT_TYPE)

Once user stopped/finished typing the message in the input box of the chat window, call the below method to send the gone status, so that they can hide a typing message in the header/recent chat.

ChatManager.sendTypingGoneStatus(TO_JID, CHAT_TYPE)

Observe the typing status#

To observe the typing status changes, you can use the below method to setup listener for the typing events.

ArgumentType
LISTENERTypingStatusListener
ChatManager.setTypingStatusListener(new TypingStatusListener() {
@Override
public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
}
@Override
public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {
}
});

Once the listener has been set by the sdk user, the below callbacks will be triggered based on the chat type.

Single chat#

for single chat below callback will be triggered

Callback arguments#

ArgumentTypeDescription
fromUserJidStringjid of the typing user
statusTypingStatusThe status param will be either composing or gone
note

composing means user is typing the message. gone means user stopped the typing

@Override
public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
}

Group chat#

for group chat below callback will be triggered

Callback arguments#

ArgumentTypeDescription
groupJidStringjid of the group in which user is typing the message
groupUserJidStringjid of the typing user
statusTypingStatusThe status param will be either composing or gone
note

composing means user is typing the message. gone means user stopped the typing

@Override
public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {
}

Mute user/Group#

If you want to mute the notifications for the chat of a user or a group, you can utilise the below method.

FlyCore.updateChatMuteStatus(JID , MUTE_STATUS);
ArgumentTypeDescription
JIDStringjid of the chat user/ group
MUTE_STATUSbooleantrue, if you want to mute notifications for the chat

Get Last seen time of a user#

if you want to get the last seen time for the chat user, you can utilise the below method.

ContactManager.getUserLastSeenTime(JID , LISTENER );
ArgumentTypeDescription
JIDStringjid of the chat user
LISTENERLastSeenListenerLastSeenListener callback to observe the action status

Check hide last seen status#

To check whether last seen status is available to friends or not, call the below method.

boolean lastSeenStatus = FlyCore.isHideLastSeenEnabled();

Get User/Group profile details#

if you want to get the profile details for the chat user, you can utilise the below method.

ProfileDetails profileDetails = ContactManager.getProfileDetails(JID);
ArgumentTypeDescription
JIDStringjid of the user

Unread count#

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

int unreadMessageCount = FlyMessenger.getUnreadMessagesCount();

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 with archived chats#

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

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

Delete a Recent Chat#

To delete a recent chat of a user or a group call the method.

FlyCore.deleteRecentChat(JID);

We can delete a archived recent chat using this method too.

ArgumentsTypeDescription
JIDStringjid of the user/group
caution

Deleting a recent chat will delete the all the conversation for that user/group including favorite messages.

Pin a Recent Chat#

To pin a recent chat which makes a particular recent chat to appear at the top of the recent chat list.

FlyCore.updateRecentChatPinStatus(JID,PIN_RECENT_CHAT);
ArgumentsTypeDescription
JIDStringjid of the user/group
PIN_RECENT_CHATbooleanif true chat will be pinned else the chat will be unpinned

Recent Chat Pinned Count#

To get the pinned count on recent chat list call the below method.

int pinnedCount = FlyCore.recentChatPinnedCount();

Clear chat messages#

Clear chat messages is a feature which allows users to delete the chat messages to reduce the storage usage. if you want to clear the messages for the entire chat, or multiple chats then you can utilise the below methods. it will also delete the downloaded media files from your local storage.

Clear chat#

You can clear the messages for any chat by using the below method. The messages will not be deleted to the receipient.

ArgumentTypeDescription
TO_JIDStringjid of the chat user
CHAT_TYPEChatTypeEnumChatTypeEnum.chat for single chat, ChatTypeEnum.groupchat for group chat, ChatTypeEnum.broadcast for broadcast
CLEAR_EXCEPT_STARREDbooleanif true, delete all the messages except the favourite messages
CALLBACKChatActionListenercallback to observe the action status
ChatManager.clearChat(TO_JID, CHAT_TYPE, CLEAR_CHAT_EXCEPT_STARRED, (isSuccess, message) -> {
});

Delete mulitple conversation#

You can delete the messages of multiple chats including group,brodcast by using the below method.

ArgumentTypeDescription
JID_LISTList<String>List of chat jid whose conversations to be deleted
CALLBACKChatActionListenercallback to observe the action status
ChatManager.deleteRecentChats(JID_LIST, (isSuccess, message) -> {
});

Delete all conversation#

You can delete the messages of all chats including group,brodcast by using the below method.

ArgumentTypeDescription
CALLBACKChatActionListenercallback to observe the action status
ChatManager.clearAllConversation((isSuccess, message) -> {
});

Mark a conversation as read#

By marking a converstaion as read the unread count will be reset and it is considered the message inside the conversation were read by you.

FlyCore.markConversationAsRead(JID_LIST);
ArgumentsTypeDescription
JID_LISTList<String>List of user/group jid

Mark a conversation as unread#

By marking a converstaion as unread it is considered the message inside the conversation were in unread state.

FlyCore.markConversationAsUnread(JID_LIST);
ArgumentsTypeDescription
JID_LISTList<String>List of user/group jid
info

The read/unread flag is available as a property in the name of isConversationUnRead in the RecentChat for a user.

Archive/Unarchive Settings#

Archive Chats Permanent status can set by enabling/disabling the option.

FlyCore.enableDisableArchivedSettings(Boolean, FlyCallback { isSuccess, throwable, data ->});
ArgumentDescriptionType
BOOLEANBooleantrue to archive the recent chat false to unarchive the recent chat

Archive Settings Status#

Get Archive Settings Status to keep the archived chats permanent.

FlyCore.isArchivedSettingsEnabled();
info

The archived settings status will be returned either True or False

Archive/Unarchive a recent chat conversation#

Archive:#

Archiving a chat conversation makes the chat not appear in recent chat list, mostly used on chats which are inactive for a long time.

UnArchive:#

Unarchiving a archived recent chat conversation makes the chat conversation appear in recent chat list again.

FlyCore.updateArchiveUnArchiveChat(JID, BOOLEAN, FlyCallback { isSuccess, throwable, data ->});
ArgumentDescriptionType
JIDStringjid of the user/group to Archive/UnArchive
BOOLEANBooleantrue to archive the recent chat false to unarchive the recent chat

Get List of archived recent chat conversation#

An archived chat won't be listed in recent chat list. To get the list of archived chats call the below method.

FlyCore.getArchivedChatsFromServer();
FlyCore.getArchivedChatList((isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<RecentChat> result = (ArrayList<RecentChat>) data.get("data")
} else {
//Getting users blocked me list failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
info

While user Logging the app, if any chats archived then list will be synced by fetching this method FlyCore.getArchivedChatsFromServer() the list of Archived JIDs will update into FlyCore.getArchivedChatList().

Search Chat Conversation#

To find a message or similar messages that matches a search term within a chat conversation between two or in a group or among all conversations call the method below.

FlyCore.searchConversation(SEARCH_TERM, JID,GLOBAL_SEARCH,
((isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<ChatMessage> result = (ArrayList<ChatMessage>) data.get("data")
} else {
//Getting search result failed print throwable to find the exception details.
}
});
ArgumentTypeDescriptionType
SEARCH_TERMStringtext characters for which search has to happen
JIDStringUnique identifier of a contact/Group (can be empty for global search)
GLOBAL_SEARCHbooleanif true then search won't be restricted by jid and search operation executes on every conversation
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
caution

Search term can't be empty, for global search pass a empty String as argument for JID.

Message Action Validation#

To get the message actions available for a list of message call the below method.

MessageActions availableMessageActions = ChatManager.getMessageActions(MESSAGE_ID_LIST);
ArgumentTypeDescription
MESSAGE_ID_LISTList<String>list of message ids

Forward Messages#

Forwarding feature helps the app users to share the single/multiple messages to one or more users.

Forward messages to single user#

if you want to forward the messages for the chat user, you can utilise the below method.

ArgumentTypeDescription
MESSAGE_ID_LISTList<String>list of message id's
TO_JIDStringjid of the chat user
CHAT_TYPEChatTypeEnumChatTypeEnum.chat for single chat, ChatTypeEnum.groupchat for group chat, ChatTypeEnum.broadcast for broadcast
CALLBACKChatActionListenercallback to observe the action status
ChatManager.forwardMessages(MESSAGE_ID_LIST, TO_JID, CHAT_TYPE, (isSuccess, message) -> {
});

Forward messages to multiple users#

if you want to forward the messages to the multiple users, you can utilise the below method.

ArgumentTypeDescription
MESSAGE_ID_LISTList<String>list of message id's
ROSTER_LISTList<Roster>jid list of the chat users
CALLBACKChatActionListenercallback to observe the action status
ChatManager.forwardMessagesToMultipleUsers(MESSAGE_ID_LIST, ROSTER_LIST, (isSuccess, message) -> {
});

Copy Messages#

To copy text messages to the android clipboard call the below method.

ChatManager.copyTextMessages(MESSAGE_ID_LIST);
ArgumentTypeDescription
MESSAGE_ID_LISTList<String>list of message ids
info

Only text messages can be copied to clipboard as of now.

Save unsent message#

To save a message which is not sent yet but typed can be saved for each user/group can be done by calling the below method.

FlyMessenger.saveUnsentMessage(JID,MESSAGE);
ArgumentTypeDescription
JIDStringJid of the user/group
MESSAGEStringText message content

Get unsent message of a user/group#

To get the saved unsent message of a user/group call the below method.

String unsentMessage = FlyMessenger.getUnsentMessageOfAJid(JID);
ArgumentTypeDescription
JIDStringJid of the user/group
TEXT_MESSAGEStringText message content

Save custom value to the message#

To save a custom value to the message which can be saved and mapped for each message can be done by calling the below method.

FlyMessenger.setCustomValue(MESSAGE_ID,KEY,VALUE);
ArgumentTypeDescription
MESSAGE_IDStringUnique Id of a ChatMessage
KEYStringUnique Key for the Value
VALUEStringValue message content

Note : Multiple custom values can be stored to the message with different unique keys.

Get custom value of a message#

To get the custom value of a message call the below method.

String customValue = FlyMessenger.getCustomValue(MESSAGE_ID,KEY);
ArgumentTypeDescription
MESSAGE_IDStringUnique Id of a ChatMessage
KEYStringUnique Key for the Value

Remove custom value of a message#

To remove the custom value of a message call the below method.

FlyMessenger.removeCustomValue(MESSAGE_ID,KEY);
ArgumentTypeDescription
MESSAGE_IDStringUnique Id of a ChatMessage
KEYStringUnique Key for the Value

Export chat conversation#

To export a chat conversation of a user, or a group call the below method.

FlyCore.prepareChatConversationToExport(JID,((isSuccess, throwable, data) -> {
if (isSuccess) {
ChatDataModel chatDataModel = (ChatDataModel) data.get("data")
// ChatDataModel has the every data to export the chat
} else {
//Exporting chat data failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
JIDStringjid of the user/group
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Note : To know more about ChatDataModel, refer class documentation.

Email Chat Conversation#

To export a chat conversation of a user, or a group to a list of email recipients call the below method.

FlyCore.exportChatConversationToEmail(JID,EMAIL_RECIPIENTS_LIST);
ArgumentTypeDescription
JIDStringjid of the user/group
EMAIL_RECIPIENTS_LISTArrayList<String>List of Strings holds the recipients email address. List can be empty but not null.
info

Email chat internally call the exportChatConversation() method and presents a share intent to export chat via email

Invite a user#

if you want to invite a user to the chat app, you can utilise the below method.

ContactManager.inviteUserViaSMS(MOBILE_NUMBER ,MESSAGE );
ArgumentTypeDescription
MOBILE_NUMBERStringmobile number to send a invite message
MESSAGEStringinvite message content

Send Feedback/Contact Us Info#

To send feedback information from the user, you can call the below method.

ContactManager.sendContactUsInfo(TITLE ,DESCRIPTION, (isSuccess, throwable, data) -> {
if (isSuccess) {
// Feedback data sent successfully
} else {
//Sending feedback data failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
TITLEStringtitle for the feedback
DESCRIPTIONStringdetailed info about the feedback
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Backup your chat#

Whenever you need to backup your chat messages, you can use the below method to start backup. The method will backup all the chats and writes to a file. Once backup completed you can get the backup file path from the onSuccess callback.

ArgumentTypeDescription
BACKUP_LISTENERBackupListenerlistener to observe the backup events
BackupManager.startBackup(new BackupListener() {
@Override
public void onProgressChanged(int percentage) {
}
@Override
public void onSuccess(@NonNull String backUpFilePath) {
}
@Override
public void onFailure(@NonNull String reason) {
}
});

while the backup is running, if you want to cancel the backup you can use the below method

BackupManager.cancelBackup();

Restore from a backup file#

Whenever you need to restore the chat messages from the backup file, you can use the below method.

ArgumentTypeDescription
BACKUP_FILEFilebackup file
RESTORE_LISTENERRestoreListenerlistener to observe the restore events
RestoreManager.restoreData(BACKUP_FILE, new RestoreListener() {
@Override
public void onProgressChanged(int percentage) {
}
@Override
public void onSuccess() {
}
@Override
public void onFailure(@NonNull String reason) {
}
});

while the restore backup is running, if you want to cancel the restore operation you can use the below method

RestoreManager.cancelRestore();

Note: Depending on the chat messages size the above methods may take long time for completion.

info

Cancelling restore operation will lead to partial db data, so avoid cancelling restore operation in most scenarios.

Delete Account#

To delete the chat account call the below method.

FlyCore.deleteAccount(REASON, FEEDBACK, (FlyCallback) (isSuccess, throwable, hashMap) -> {
if (isSuccess) {
// Chat account has been deleted and need to re-register again to send and receive message
} else {
// Delete chat account failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
REASONStringreason for the account deletion
FEEDBACKStringdetailed feedback about the account deletion
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
info

Deleting chat account will remove all informations(messages, groups and contacts) related to this chat account

Logout of Chat SDK#

To logout of the chat SDK call the below method.

FlyCore.logoutOfChatSDK((isSuccess, throwable, data) -> {
if (isSuccess) {
// User loged out of the chat sdk need to login again to send and receive message
} else {
// Logging out failed print throwable to find the exception details.
}
});
ArgumentTypeDescription
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
caution

Once you are logged out you cannot establish a connection with chat server unless you login again.

info

Sdk is having a built-in functions to prepare the JID, Group JID.