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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MEDIA_MESSAGE_ID | String | Id of the media message |
Note : In ChatManager
.setMediaFolderNameshould 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.
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID | String | message id of the media message |
- Java
- Kotlin
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 callFlyMessenger.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:
- Java
- Kotlin
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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MEDIA_MESSAGE_ID | String | id of the media message |
| PROGRESS_STATUS | int | percentage of the file downloaded till now (0-100) |
| DATA_TRANSFERRED | long | size of the file downloaded till now |
| DOWNLOAD_STATUS | MediaDownloadStatus | status of the upload |
status value could be one of the values below:
- Java
- Kotlin
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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MEDIA_MESSAGE_ID | String | id of the media message |
| PROGRESS_STATUS | int | percentage of the file uploaded till now (0-100) |
| DATA_TRANSFERRED | long | size of the file uploaded till now |
| UPLOAD_STATUS | MediaUploadStatus | status of the upload |
status value could be one of the values below:
- Java
- Kotlin
Message Action Validation#
To get the message actions available for a list of message call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID_LIST | List<String> | list of message ids |
Copy Messages#
To copy text messages to the android clipboard call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID_LIST | List<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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | Jid of the user/group |
| MESSAGE | String | Text message content |
Get unsent message of a user/group#
To get the saved unsent message of a user/group call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | Jid of the user/group |
| TEXT_MESSAGE | String | Text 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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID | String | Unique Id of a ChatMessage |
| KEY | String | Unique Key for the Value |
| VALUE | String | Value 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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID | String | Unique Id of a ChatMessage |
| KEY | String | Unique Key for the Value |
Remove custom value of a message#
To remove the custom value of a message call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID | String | Unique Id of a ChatMessage |
| KEY | String | Unique Key for the Value |