Single chat module
#
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 |
- Swift
- Objective-C
#
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.
- Swift
- Objective-C
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
MESSAGE | String | Text message to be sent |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | FlySendMessageListener | callback to observe the action status |
#
Get messagesTo fetch all the conversation between you and a single chat user or group, call the below method.
- Swift
- Objective-C
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.
- Swift
- Objective-C
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.
- Swift
- Objective-C
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.
- Swift
- Objective-C
Argument | Type | Description |
---|---|---|
MESSAGE_MIDS | [String] | Ids of messages |
#
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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
LATITUDE | Double | location latitude which needs to be sent |
LONGITUDE | Double | location longitude which needs to be sent |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
CONTACT_NAME | String | contact name |
CONTACT_NUMBERS | List<String> | list of numbers in that contact |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
FILE | URL | video Url |
CAPTION_TEXT | String | caption text for video file |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
Video message with urlIf 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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
VIDEO_FILE_NAME | String | name of the video file |
VIDEO_FILE_URL | String | file url of the video |
VIDEO_FILE_SIZE | String | file size of the video |
VIDEO_DURATION | String | duration of the video |
THUMBNAIL_BASE64 | String | base64 encoded thumbnail image of the video |
LOCAL_FILE_PATH | String | localFilePath of the video |
VIDEO_CAPTION | String | caption text for the video |
REPLY_MESSAGE_ID | if it is a reply message for message A, then message A's messageId otherwise empty string | |
listener | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
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
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
IMAGE_FILE | URL | image Url which needs to be sent |
THUMBNAIL_BASE64 | String | base64 string representation of thumbnail of the original image |
CAPTION | String | additional text which can be sent along with the image message |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-c
#
Image message with urlTo 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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
IMAGE_FILE_NAME | String | name of the image file we are sending |
IMAGE_FILE_SIZE | String | size of the image file in bytes |
IMAGE_FILE_URL | String | url of the image file that was uploaded |
IMAGE_FILE_LOCAL_PATH | String | local path of the image file in the device |
THUMBNAIL_BASE64 | String | base64 string representation of thumbnail of the original image |
CAPTION | String | additional text which can be sent along with the image message |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
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
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
AUDIO_FILE | URL | audio Url we are sending |
AUDIO_DURATION | Long | duration of the audio file |
REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
CALLBACK | SendMessageListener | callback to observe the action status |
- Swift
- Objective-C
#
Audio message with urlTo 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.
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
AUDIO_FILE_SIZE | String | size of the audio file in bytes |
AUDIO_FILE_URL | String | url of the audio file that was uploaded |
AUDIO_FILE_LOCAL_PATH | String | local path of the audio file in the device |
AUDIO_DURATION | Long | duration of the audio file |
replyMessageId | if it is a reply message for message A, then message A's messageId otherwise empty string | |
listener | SendMessageListener callback to observe the action status |
- Swift
- Objective-C