Chat SDK for Android | Chat Android SDK

Prerequisites#

In order to send messages using the chat sdk , at first you need to establish the connection to the server. sdk provides methods for initializing the connection configuration as well as methods for making connection.

Note: Even if you don't have internet connection, you are still allowed to send messages which will be kept in offline database.Once the user connected to the internet, the messages will be sent automatically when user opens the app.

Preparing single chat jid#

Almost of the sdk methods expect jid as a input parameter, so sdk provides below utility method to prepare the jid. The method prepares the single chat jid from the given string by using chat config provided via [com.contusflysdk.api.ChatConnectionManager.initialize] method.

Note: The below characters is not allowed in uniqueId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@).

ArgumentTypeDescription
UNIQUE_USER_IDStringunique userId for preparing JID
FlyUtils.getJid(UNIQUE_USER_ID)

Text message#

Text is a basic form of communication between users. sdk provides methods to send the text message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the text message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
TEXTStringtext message to be sent
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
MENTION_IDSList<String>list of userId to mention specific users while sending a group message, otherwise it will be empty
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendTextMessage(TO_JID, TEXT, REPLY_MESSAGE_ID, MENTION_IDS, new SendMessageListener() {
@Override
public void onResponse(boolean isSuccess, @Nullable ChatMessage chatMessage) {
// you will get the message sent success response
}
});

Location message#

Location sharing is a famous communication between users. sdk provides methods to send the location message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the location message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
LATITUDEDoublelocation latitude which needs to be sent
LONGITUDEDoublelocation longitude which needs to be sent
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendLocationMessage(TO_JID, LATITUDE, LONGITUDE, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

Contact message#

Contact sharing is very useful communication between users. sdk provides methods to send the contact message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the contact message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
CONTACT_NAMEStringcontact name
CONTACT_NUMBERSList<String>list of numbers in that contact
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendContactMessage(TO_JID, CONTACT_NAME, CONTACT_NUMBERS, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

Document message#

Document sharing is very useful communication between users. sdk provides methods to send the document message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the document message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
FILEFiledocument file object
FILE_NAMEStringname of the document
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendDocumentMessage(TO_JID, FILE, FILE_NAME ,REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

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.

Document message with url#

If you have uploaded the document to your own media server and the you want to share document with other user. sdk provides methods to send the document message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the document message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
FILE_NAMEStringname of the document
FILE_SIZEStringfile size of the document
FILE_URLStringfile url of the document
LOCAL_FILE_PATHStringlocalFilePath of the document
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendDocumentMessage(TO_JID, FILE_NAME, FILE_SIZE, FILE_URL, LOCAL_FILE_PATH, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

Video message#

Video sharing is very useful communication between users. sdk provides methods to send the video message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the video message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
FILEFilevideo file object
CAPTION_TEXTStringcaption text for video file
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
MENTION_IDSList<String>list of userId to mention specific users while sending a group message, otherwise it will be empty
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendVideoMessage(TO_JID, FILE, CAPTION_TEXT, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

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.

Video message with url#

If you have uploaded the video to your own media server and the you want to share video with other user. sdk provides methods to send the video message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the video message for a user, you can utilise the below method.

ArgumentTypeDescription
TO_JIDStringjid of the end user
MEDIA_DATAMediaDatastruct to hold the metadata of the video file
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
MENTION_IDSList<String>list of userId to mention specific users while sending a group message, otherwise it will be empty
LISTENERSendMessageListenercallback to observe the action status
FlyMessenger.sendVideoMessage(TO_JID, MEDIA_DATA, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

Image message#

To send image as a message call the below method. Calling the below method will upload the image file to the server provided during sdk initialization then send the message

ArgumentTypeDescription
TO_JIDStringjid of the end user
IMAGE_FILEFileimage File which needs to be sent
THUMBNAIL_BASE64Stringbase64 string representation of thumbnail of the original image
CAPTIONStringadditional text which can be sent along with the image message
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
MENTION_IDSList<String>list of userId to mention specific users while sending a group message, otherwise it will be empty
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendImageMessage(TO_JID, IMAGE_FILE, THUMBNAIL_BASE64, CAPTION, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

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.

Image message with url#

To send image as a message call the below method. You can upload the image file to your storage of choice and send the url and other necessary info while sending the message.

ArgumentTypeDescription
TO_JIDStringjid of the end user
MEDIA_DATAMediaDatastruct to hold the metadata of the image file
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
MENTION_IDSList<String>list of userId to mention specific users while sending a group message, otherwise it will be empty
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendImageMessage(TO_JID, MEDIA_DATA, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

Audio message#

To send audio as a message call the below method. Calling the below method will upload the audio file to the server provided during sdk initialization then send the message

ArgumentTypeDescription
TO_JIDStringjid of the end user
AUDIO_FILEFileaudio File we are sending
AUDIO_DURATIONLongduration of the audio file
IS_RECORDEDBooleantrue, if audio file is recorded.false, if audio file is attached.
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string
CALLBACKSendMessageListenercallback to observe the action status
FlyMessenger.sendAudioMessage(TO_JID, AUDIO_FILE, AUDIO_DURATION, IS_RECORDED, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

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.

Audio message with url#

To send audio as a message call the below method. You can upload the audio file to your storage of choice and send the url and other necessary info while sending the message.

ArgumentTypeDescription
TO_JIDStringjid of the end user
MEDIA_DATAMediaDatastruct to hold the metadata of the audio file
IS_RECORDEDBooleantrue if the audio file is a recoreded or voice message else false
replyMessageIdStringif it is a reply message for message A, then message A's messageId otherwise empty string
listenerSendMessageListenercallback to observe the action status
FlyMessenger.sendAudioMessage(TO_JID, MEDIA_DATA,
REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
caution

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

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.

To get the uploaded/downloaded status of a media message Refer the snippet below.

For received media message:

ChatMessage message = FlyMessenger.getMessageOfId(MEDIA_MESSAGE_ID);
MediaChatMessage mediaMessage = message.getMediaChatMessage();
@MediaDownloadStatus int mediaStatus = mediaMessage.getMediaDownloadStatus();
//The possible values of mediaStatus were
MediaDownloadStatus.MEDIA_DOWNLOADING
MediaDownloadStatus.MEDIA_DOWNLOADED
MediaDownloadStatus.MEDIA_NOT_DOWNLOADED
MediaDownloadStatus.MEDIA_DOWNLOADED_NOT_AVAILABLE

For sent media message:

ChatMessage message = FlyMessenger.getMessageOfId(MEDIA_MESSAGE_ID);
MediaChatMessage mediaMessage = message.getMediaChatMessage();
@MediaUploadStatus int mediaStatus = mediaMessage.getMediaUploadStatus();
//The possible values of mediaStatus were
MediaUploadStatus.MEDIA_NOT_UPLOADED
MediaUploadStatus.MEDIA_UPLOADING
MediaUploadStatus.MEDIA_UPLOADED
MediaUploadStatus.MEDIA_UPLOADED_NOT_AVAILABLE
ArgumentTypeDescription
MEDIA_MESSAGE_IDStringid of a message

Delete Messages#

Delete messsage is a feature which is found in modern messaging apps which allows the user to delete the message once it is sent.Once you sent the message, you can able to delete the messages by using built in sdk methods.

Delete for me#

If you want to delete the messages for yourself only then you can use the below method.

Note: The messages will not be deleted to the receipient.

ArgumentTypeDescription
TO_JIDStringjid of the chat user
MESSAGE_ID_LISTList<String>List of messageId to be deleted
DELETE_CHAT_TYPEDeleteChatTypeDeleteChatType.chat for single chat, DeleteChatType.groupchat for group chat
CALLBACKChatActionListenercallback to observe the action status
ChatManager.deleteMessagesForMe(TO_JID, MESSAGE_ID_LIST, DELETE_CHAT_TYPE, (isSuccess, message) -> {
});
Delete for everyone#

If you want to delete the messages for yourself and receiver then you can use the below method. The messages will also be deleted to the receipient.

ArgumentTypeDescription
TO_JIDStringjid of the chat user
MESSAGE_ID_LISTList<String>List of messageId to be deleted
DELETE_CHAT_TYPEDeleteChatTypeDeleteChatType.chat for single chat, DeleteChatType.groupchat for group chat
CALLBACKChatActionListenercallback to observe the action status
ChatManager.deleteMessagesForEveryone(TO_JID, MESSAGE_ID_LIST, DELETE_CHAT_TYPE, (isSuccess, message) -> {
});
caution

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

Favourite Messages#

Favourite messags is feature which allows users to mark some messages as favourites. so that they can see those important messages in future without searching for them in chat. Once you marked messages as favourite, you can get those from sdk to show it in your app's screen.

ArgumentTypeDescription
MESSAGE_IDStringmessageId of the message
CHAT_USER_JIDStringjid of the chat user
IS_FAVOURITEbooleantrue, if you are adding to favourites.false to remove from favourites
CALLBACKChatActionListenercallback to observe the action status
Make favourite#

You can mark the messages as favourite by using the below method.

ChatManager.updateFavouriteStatus(MESSAGE_ID, CHAT_USER_JID, true, (isSuccess, message) -> {
});
Remove favourite#

You can remove the messages from favourite by using the below method.

ChatManager.updateFavouriteStatus(MESSAGE_ID, CHAT_USER_JID, false, (isSuccess, message) -> {
});
Get all favourite messages#

The below method will return all the favourite messages from the local db.

List<ChatMessage> favouriteMessages = FlyMessenger.getFavouriteMessages();
Unfavorite all the favourite messages#

You can unfavourite all the favourite messages by using the below method.

ChatManager.unFavouriteAllFavouriteMessages((isSuccess, message) -> {
if(isSuccess){
//Unfavourite success update the UI
}else{
// Unfavourite failed print message to know the error
}
})
caution

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

Message receipts#

info

To obserserve message's sent, delivered, read status refer the message callback listeners.

Message receipts is a feature which allows users to know the status of the sent messages as well as the delivered and read time for the messages. The chat app users are well informed about the status of the sent messages.

You need to update the ongoing chat user jid always whenever you are entering/exiting the chat window of user by using below method. it is used by sdk internally for receipts.

In activity/fragment onResume, set the user jid as ongoing chat user.

ArgumentTypeDescription
JIDStringjid of the chat user
@Override
public void onResume() {
super.onResume();
ChatManager.setOnGoingChatUser(JID);
}

Then, in activity/fragment onPause, clear the ongoing chat user.

@Override
public void onPause() {
super.onPause();
ChatManager.setOnGoingChatUser("");
}

Mark messages as delivered#

You don't need to send the delivery receipts explicitly, it will be automatically sent by the sdk.

Mark messages as read#

Once the user reads the messages of user B or entered into the chat window of user B, you can mark the messages as read by using the below method. In this case user B's jid will be passed to the below method. Then read receipts will be managed by sdk. sdk will utilise the ongoing chat user jid which is set by this method ChatManager.setOnGoingChatUser(jid: String)

ArgumentTypeDescription
JIDStringjid of the chat user
ChatManager.markAsRead(JID)
info

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

Get single chat message status#

To get the time of sent, delivered and seen status of a message sent by you in a single one to one chat call the below method.

ChatMessageStatusDetail messageStatus = FlyMessenger.getMessageStatusOfASingleChatMessage(MESSAGE_ID);
ArgumentTypeDescription
MESSAGE_IDStringmessage id of the message

Get messages of a user/group by pagination#

####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);
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

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 messages of a user/group#

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

List<ChatMessage> messages = FlyMessenger.getMessagesOfJid(JID);
ArgumentTypeDescription
JIDStringJid of the user/group

Get message from db#

Whenever you get callbacks from MessageEventsListener, you will get messageId sometimes at those times you can fetch the message from db using the below method and then update your list as well as notify the list view.

ChatMessage message = FlyMessenger.getMessageOfId(MESSAGE_ID);
ArgumentTypeDescription
MESSAGE_IDStringmessageId of the message

Get messages using id#

To get list of messages from a given message id's call the below method.

List<ChatMessage> messages = ChatManager.getMessagesUsingIds(MESSAGE_ID_LIST);

Remove unread message separator#

To remove the unread message separator in a chat conversation list call the below method.

FlyMessenger.deleteUnreadMessageSeparatorOfAConversation(JID);
ArgumentTypeDescription
JIDStringJid of the user/group

Get recalled messages of a user/group#

To get the recalled messages of a user/group call the below method.

List<ChatMessage> recalledMessages = FlyMessenger.getRecalledMessagesOfAConversation(JID);
ArgumentTypeDescription
JIDStringJid of the user/group

Upload/Download media message#

Whenever you receive a media message from a user, or when retrying to upload a already sent media message you can use built-in sdk functions to upload/download the media content / The below method is applicable only if you are using sdk media server, otherwise you have to handle uploading/downloading the media by your own implementation as well as update the status of the media message.

FlyMessenger.uploadMedia(isRetry, MEDIA_MESSAGE_ID);
FlyMessenger.downloadMedia(MEDIA_MESSAGE_ID);
ArgumentTypeDescription
isRetryBooleanIf false for the first time video upload will compress the size and send, If true the video upload file will not compress again (avoid duplicates)
MEDIA_MESSAGE_IDStringId of the media message

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

Update media status#

Update media download status#

If you are using your own media service, whenever the media downloading status is changed, you have to update the media message status like below.

ChatManager.updateMediaDownloadStatus(MEDIA_MESSAGE_ID,PROGRESS_STATUS,DATA_TRANSFERRED,DOWNLOAD_STATUS);
ArgumentTypeDescription
MEDIA_MESSAGE_IDStringid of the media message
PROGRESS_STATUSintpercentage of the file downloaded till now (0-100)
DATA_TRANSFERREDlongsize of the file downloaded till now
DOWNLOAD_STATUSMediaDownloadStatusstatus of the upload

status value could be one of the values below:

MediaDownloadStatus.MEDIA_DOWNLOADING
MediaDownloadStatus.MEDIA_DOWNLOADED
MediaDownloadStatus.MEDIA_NOT_DOWNLOADED
MediaDownloadStatus.MEDIA_DOWNLOADED_NOT_AVAILABLE;
Update media upload status#

If you are using your own media service, whenever the media uploading status is changed, you have to update the media message status like below.

ChatManager.updateMediaUploadStatus(MEDIA_MESSAGE_ID,PROGRESS_STATUS,DATA_TRANSFERRED,UPLOAD_STATUS);
ArgumentTypeDescription
MEDIA_MESSAGE_IDStringid of the media message
PROGRESS_STATUSintpercentage of the file uploaded till now (0-100)
DATA_TRANSFERREDlongsize of the file uploaded till now
UPLOAD_STATUSMediaUploadStatusstatus of the upload

status value could be one of the values below:

MediaUploadStatus.MEDIA_NOT_UPLOADED
MediaUploadStatus.MEDIA_UPLOADING
MediaUploadStatus.MEDIA_UPLOADED
MediaUploadStatus.MEDIA_UPLOADED_NOT_AVAILABLE

Cancel upload/download#

Whenever you would like to cancel upload/download of a media message , you can use built-in sdk functions to cancel the media content upload/download.The below method is applicable only if you are using sdk media server, otherwise you have to handle cancelling the media by your own implementation as well as update the status of the media message.

ArgumentTypeDescription
MESSAGE_IDStringmessage id of the media message
FlyMessenger.cancelMediaUploadOrDownload(MESSAGE_ID)

When the user cancelled the media download, then user need to restart the download using FlyMessenger.downloadMedia(messageId: String) method. In case of media upload, the upload initiated once the user sent the message In case of retry call FlyMessenger.uploadMedia(messageId: String).

info

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

Upload/Download push notification tap action#

Whenever you would like to add tap action for Upload/Download push notification, you can use built-in sdk functions to add action listener to upload/download push notification. The below method is applicable only if you are using sdk media server, otherwise you have to handle tap action by your own implementation.

In your application class oncreate method add the below method:

ChatManager.setMediaNotificationHelper((notificationCompatBuilder, toUsers) -> {
// Add your setContentIntent to notificationCompatBuilder here by using jidList which has uploading/downloading media files
});

Encrypt/Decrypt media files#

To encrypt all media files while uploading to server, call below method to enable media encryption in SDK

ChatManager.setMediaEncryption(true)

Note: If this flag enabled then all type of media files will be encrypted while uploading and stored in server, On receiver side media files will be decrypted while downloading and readable file will be stored in local storage.

Delete all messages in local db#

To delete all the chat conversation messages and their relevent data like message statuses call the below method.

FlyMessenger.deleteAllMessages();