Managing a Message

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(MEDIA_MESSAGE_ID);
FlyMessenger.downloadMedia(MEDIA_MESSAGE_ID);
ArgumentTypeDescription
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.

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

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.

FlyMessenger.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
MediaDownloadStatus.STORAGE_NOT_ENOUGH

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.

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

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

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

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