Retrieve Messages
Get a message#
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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_ID | String | messageId of the message |
Get messages using id's#
To get list of messages from a given message id's call the below method.
- Java
- Kotlin
Get messages of a user/group#
To fetch all the conversation between you and a single chat user or group, call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | Jid of the user/group |
Get messages of a user/group via 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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | Jid of the user/group |
| MESSAGE_ID | String | Message id of the starting point optional |
| MESSAGE_TIME | String | Message time of the starting point optional |
| INCLUSIVE | boolean | If true starting point message will included in message list default false |
| ASCENDING_ORDER | boolean | If true message list will be returned ascendingOrder by message time default false |
| LIMIT | int | No of messages will be fetched for each request default 50 |
| TOPIC_ID | String | Topic Id to be fetched |
Second, create a FetchMessageListQuery instance.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MESSAGE_LIST_PARAM | FetchMessageListParams | Insatance of 'FetchMessageListParams' |
Load Initial Messages#
To fetch initial conversations between you and a single chat user or group, call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| CALLBACK | FlyCallback | '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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| CALLBACK | FlyCallback | '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.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| CALLBACK | FlyCallback | '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.
- Java
- Kotlin
Note : The
hasPreviousMessages()method is used to check if previous messages are available in the local database only. It does not apply to users withChatHistoryenabled, as their message history is retrieved from the server
Check Next Set of Messages Available#
To check next set of conversations available or not, call the below method.
- Java
- Kotlin
Note : The
hasNextMessages()method is used to check if next messages are available in the local database only. It does not apply to users withChatHistoryenabled, as their message history is retrieved from the server
Check Message Fetching InProgress#
To check conversations fetching in progress or not, call the below method.
- Java
- Kotlin
Get media messages#
If you want to get the media messages for a user/group, you can utilise the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | jid 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:
- Java
- Kotlin
For sent media message:
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| MEDIA_MESSAGE_ID | String | id of a message |
Get recalled messages of a user/group#
To get the recalled messages of a user/group call the below method.
- Java
- Kotlin
| Argument | Type | Description |
|---|---|---|
| JID | String | Jid of the user/group |