Single chat
#
PrerequisitesIn 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 jidAlmost 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 (@).
Argument | Type | Description |
---|---|---|
UNIQUE_USER_ID | String | unique userId for preparing JID |
#
Text messageText 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.
To send your text message, you need to pass the TextMessage
object as an argument to the parameter in the sendTextMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | TextMessage | Object to hold the parameters of the text message |
CALLBACK | FlySendMessageListener | callback to observe the action status |
#
Location messageLocation 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.
To send your location message, you need to pass the FileMessage
object with LocationMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the location message |
CALLBACK | FlySendMessageListener | callback to observe the action status |
caution
If Location attachment feature unavailable for your plan then it will throw 403 exception.
#
Contact messageContact 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.
To send your contact message, you need to pass the FileMessage
object with ContactMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the contact message |
CALLBACK | FlySendMessageListener | callback to observe the action status |
caution
If Contact attachment feature unavailable for your plan then it will throw 403 exception.
#
Document messageDocument 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.
To send your document message, you need to pass the FileMessage
object with FileMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the document message |
CALLBACK | FlySendMessageListener | callback to observe the action status |
caution
If Document attachment feature unavailable for your plan then it will throw 403 exception.
#
Video messageVideo 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.
To send your video message, you need to pass the FileMessage
object with FileMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the video message |
LISTENER | FlySendMessageListener | callback to observe the action status |
To get the metadata of a video file for sending videos make use of the utility methods
MediaUtils.processVideo()
andMediaUtils.compressVideo()
caution
If Video attachment feature unavailable for your plan then it will throw 403 exception.
#
Image messageTo 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
To send your image message, you need to pass the FileMessage
object with FileMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the image message |
CALLBACK | FlySendMessageListener | callback to observe the action status |
To get the metadata of an image file for sending images make use of the utility methods
MediaUtils.getAssetsImageInfo()
andMediaUtils.compressImage()
caution
If Image attachment feature unavailable for your plan then it will throw 403 exception.
#
Audio messageTo 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
To send your audio message, you need to pass the FileMessage
object with FileMessageParams
set as an argument to the parameter in the sendFileMessage()
method.
Argument | Type | Description |
---|---|---|
MESSAGE_PARAMS | FileMessage | Object to hold the parameters of the audio message |
listener | FlySendMessageListener | callback to observe the action status |
To get the metadata of an audio file for sending audio make use of the utility method
MediaUtils.processAudio()
caution
If Audio attachment feature unavailable for your plan then it will throw 403 exception.
#
Get messagesTo fetch all the conversation between you and a single chat user or group, call the below method.
Argument | Type | Description |
---|---|---|
JID | String | Jid of the chat user/group |
#
Get media messagesTo get the media messages of a conversation, call the below method.
Argument | Type | Description |
---|---|---|
JID | String | Jid of the chat user/group |
To get Video, Image, and Audio messages a conversation, call the below method. It is used in view all media to get array of messages group by month
Argument | Type | Description |
---|---|---|
jid | String | Jid of the chat user/group |
#
Get Single messageTo get a single message from database using a message id, call the below method.
Argument | Type | Description |
---|---|---|
MESSAGE_MID | String | Id of a message |
#
Get messages using idsTo get array of messages from database using their message ids, call the below method.
Argument | Type | Description |
---|---|---|
MESSAGE_MIDS | [String] | Ids of messages |
#
Remove unread message separatorTo remove the unread message separator in a chat conversation list call the below method.
Argument | Type | Description |
---|---|---|
JID | String | Jid of the user/group |
#
Favourite MessagesFavourite 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.
Argument | Type | Description |
---|---|---|
MESSAGE_ID | String | messageId of the message |
CHAT_USER_JID | String | jid of the chat user |
IS_FAVOURITE | boolean | true, if you are adding to favourites.false to remove from favourites |
CALLBACK | ChatActionListener | callback to observe the action status |
#
Make favouriteYou can mark the messages as favourite by using the below method.
#
Remove favouriteYou can remove the messages from favourite by using the below method.
#
Get all favourite messagesThe below method will return all the favourite messages from the local db.
#
Upload/Download media messageWhenever 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.
Argument | Type | Description |
---|---|---|
MEDIA_MESSAGE_ID | String | MessageID of the ChatMeassage |
Note: Use same methods for Upload/Download Media Retry.
#
Delete messagesDelete 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 meIf 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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
MESSAGE_ID_LIST | [String] | List of messageId to be deleted |
DELETE_CHAT_TYPE | DeleteChatType | DeleteChatType.chat for single chat, DeleteChatType.groupchat for group chat |
ISREVOKE_MEDIA_ACCESS | Boolean | True - selected media file can be deleted,False - selected media file cannot be deleted |
CALLBACK | DeleteMessageListener | callback to observe the action status |
caution
If delete message feature unavailable for your plan then below methods will throw 403 exception.
caution
If delete message feature unavailable for your plan then below methods will throw 403 exception.
#
Delete for everyoneIf 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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
MESSAGE_ID_LIST | [String] | List of messageId to be deleted |
DELETE_CHAT_TYPE | DeleteChatType | DeleteChatType.chat for single chat, DeleteChatType.groupchat for group chat |
ISREVOKE_MEDIA_ACCESS | Boolean | True - selected media file can be deleted,False - selected media file cannot be deleted |
CALLBACK | DeleteMessageListener | callback to observe the action status |
caution
If delete message feature unavailable for your plan then below methods will throw 403 exception.
caution
If delete message feature unavailable for your plan then below methods will throw 403 exception.
#
Cancel upload/downloadWhenever 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.
Argument | Type | Description |
---|---|---|
MESSAGE_ID | String | message id of the media message |
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)
.