sendMessage()
method and pass a TextMessage
object to it.
TextMessage
. A metadata field is a dictionary
of type [String: Any]
which will be received as it was sent without any processing from CometChat. It can be used to send any additional data that needs to be sent along with a message.
Array
of strings that you need to set it to property tags
.
sendMessage()
method to send the text message to the recipient.
TextMessage
class constructor takes the following parameters:
Parameters | Information |
---|---|
receiverID | The UID or GUID of the recipient |
text | The text to be sent |
receiverType | The type of the receiver to whom the message is to be sent i.e user or group |
TextMessage
object which includes all information related to the sent message.
sendMediaMessage()
method and pass a MediaMessage
object to it.
MediaMessage
. A metadata field is a dictionary
of type [String: Any]
which will be received as it was sent without any processing from CometChat. It can be used to send any additional data that needs to be sent along with a message.
setCaption
method and pass text to it.
Array
of strings that you need to set it to property tags
.
MediaMessage
class. The initialize method of the MediaMessage
class takes the following mandatory parameters:
Parameter | Description | |
---|---|---|
receiverId | The UID or GUID of the recipient | Required |
fileurl | The file path object to be sent | Required |
messageType | The type of the message that needs to be sent which in this case can be: - image - video - audio - file | Required |
receiverType | The type of the receiver to whom the message is to be sent - user - group | Required |
MediaMessage
class containing all the information related to the sent media message.
If you wish to send a caption or some text along with the Media Message, you can use the caption field
provided by the MediaMessage class. To set the caption you can use the setCaption()
method and at the receiver end, you can obtain the caption using the getCaption()
method. As with text messages, the metadata field can be used with media messages as well. Any additional information can be passed along with the media message as a JSONObject
.
sendMediaMessage()
method, the files are uploaded to the CometChat servers & the URL of the files are sent in the success response of the sendMediaMessage()
method.MediaMessage
class constructor takes the following parameters:
Parameter | Description |
---|---|
receiverId | The UID or GUID of the recipient. |
files | An array of File object. File object is made of name and data of the file |
messageType | The type of the message that needs to be sent which in this case can be: 1. CometChatConstants.MESSAGE_TYPE_IMAGE 2. CometChatConstants.MESSAGE_TYPE_VIDEO 3. CometChatConstants.MESSAGE_TYPE_AUDIO 4. CometChatConstants.MESSAGE_TYPE_FILE |
receiverType | The type of the receiver to whom the message is to be sent. 1. CometChatConstants.RECEIVER_TYPE_USER 2. CometChatConstants.RECEIVER_TYPE_GROUP |
Attachment
class. For more information, you can refer to the below code snippet:MediaMessage
object which includes all information related to the sent message.
You can use the setMetadata()
, setCaption()
& setTags()
methods to add metadata, caption and tags respectively in exactly the same way as it is done while sending a single file or attachment in a Media Message.
sendCustomMessage()
method.
The sendCustomMessage()
methods takes an object of the CustomMessage
which can be obtained using the below two constructor:
custom
.
The parameters involved are:
CustomMessage
class to set a specific type for the CustomeMessage.
Array
of strings that you need to set it to property tags
.
CustomMessage
class is ready you can send the custom message using the sendCustomMessage()
method.
CustomMessage
class.
Push, Email & SMS
notification of a custom message you can use the conversationText
property of Custom Message class.