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.

FlyChat.reportUserOrMessages(TO_USER_ID, CHAT_TYPE, SELECTED_MID).
then((bool? value) {
//report success
}).catchError((onError) {
//report failed
});

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.

FlyChat.onAdminBlockedUser.listen(result) {
}
// To get the own user admin block/unblock status by using the below method while app is opening from background
FlyChat.getIsProfileBlockedByAdmin().then((bool? value) {
//report success
})

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.

FlyChat.onAdminBlockedOtherUser.listen(result) {
}

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.

FlyChat.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.

FlyChat.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
TO_JIDString
CHAT_TYPEString
FlyChat.onChatTypingStatus.listen(result) {
}

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

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

FlyChat.onGroupTypingStatus.listen(result) {
}

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.

FlyChat.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.

FlyChat.getUserLastSeenTime(JID).then((String? value) {
});
ArgumentTypeDescription
JIDStringjid of the chat user

Check hide last seen status#

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

FlyChat.isHideLastSeenEnabled().then((bool? value) {
});

Get User/Group profile details#

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

FlyChat.getProfileDetails(JID, false).then((value) {
var data = Profile.fromJson(json.decode(value.toString()));
});
ArgumentTypeDescription
JIDStringjid of the user

Unread count#

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

FlyChat.getUnreadMessagesCount().then((int? value) {
});

Get Recent Chat#

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

var value = await FlyChat.getRecentChatOf(JID);
var data = RecentChatData.fromJson(json.decode(value));

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.

FlyChat.getRecentChatList().then((value) {
var data = recentChatFromJson(value);
}).catchError((error) {
// Error handling
});

Get Recent Chat list with archived chats#

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

FlyChat.getRecentChatListIncludingArchived().then((value) {
var js = json.decode(value);
var recentChatListWithArchived = List<RecentChatData>.from(js.map((x) => RecentChatData.fromJson(x)));
});

Delete a Recent Chat#

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

FlyChat.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.

FlyChat.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.

FlyChat.recentChatPinnedCount().then((int? value) {
});

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
FlyChat.clearChat(TO_JID, CHAT_TYPE, CLEAR_CHAT_EXCEPT_STARRED).then((bool value) {
});

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
FlyChat.deleteRecentChats(JID_LIST).then((bool? value) {
});

Delete all conversation#

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

FlyChat.clearAllConversation().then((bool? value) {
});

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.

FlyChat.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.

FlyChat.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.

FlyChat.enableDisableArchivedSettings(Boolean).then((bool? value) {
});
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.

FlyChat.isArchivedSettingsEnabled().then((bool? value) {
});
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.

FlyChat.updateArchiveUnArchiveChat(JID, Boolean).then((bool? value) {
});
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.

FlyChat.getArchivedChatsFromServer();
FlyChat.getArchivedChatList().then((value) {
});
info

While user Logging the app, if any chats archived then list will be synced by fetching this method FlyChat.getArchivedChatsFromServer() the list of Archived JIDs will update into FlyChat.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.

await FlyChat.searchConversation(SEARCH_TERM).then((value) {
var result = chatMessageFromJson(value);
});
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
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.

await FlyChat.getMessageActions(MESSAGE_ID_LIST).then((value) {
});
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_TYPEStringchat/groupchat
FlyChat.forwardMessages(MESSAGE_ID_LIST, TO_JID, CHAT_TYPE).then((value) {
});

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
FlyChat.forwardMessagesToMultipleUsers(MESSAGE_ID_LIST, ROSTER_LIST).then((value) {
});

Copy Messages#

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

FlyChat.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.

FlyChat.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.

FlyChat.getUnsentMessageOfAJid(JID).then((String? value) {
});
ArgumentTypeDescription
JIDStringJid of the user/group

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.

FlyChat.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.

FlyChat.getCustomValue(MESSAGE_ID, KEY).then((String? value) {
});
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.

FlyChat.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.

FlyChat.prepareChatConversationToExport(JID).then((value) {
});
ArgumentTypeDescription
JIDStringjid of the user/group

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.

FlyChat.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.

FlyChat.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.

FlyChat.sendContactUsInfo(TITLE, DESCRIPTION)).then((bool? value){
});
ArgumentTypeDescription
TITLEStringtitle for the feedback
DESCRIPTIONStringdetailed info about the feedback

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
FlyChat.startBackup();
FlyChat.onFailure.listen(result) {
}
FlyChat.onProgressChanged.listen(result) {
}
FlyChat.onSuccess.listen(result){
}

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

FlyChat.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
FlyChat.restoreData();
FlyChat.onFailure.listen(result) {
}
FlyChat.onProgressChanged.listen(result) {
}
FlyChat.onSuccess.listen(result){
}

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

FlyChat.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.

FlyChat.deleteAccount(REASON, FEEDBACK).then((value) {
}).catchError((error) {
// Error handling
});
ArgumentTypeDescription
REASONStringreason for the account deletion
FEEDBACKStringdetailed feedback about the account deletion
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.

FlyChat.logoutOfChatSDK().then((value) {
}).catchError((er){
});
caution

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

info

Logout function will not clear messages and groups data in Chat database.

info

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

Clear all data in Chat SDK#

To clear all SDK data in the database and preference call the below method.

FlyChat.clearAllSDKData();