sendMessage()
method and pass a TextMessage
object to it.
TextMessage
class constructor takes the following parameters:
Parameter | Description | |
---|---|---|
receiverID | UID of the user or GUID of the group receiving the message | Required |
messageText | The text message | Required |
receiverType | The type of the receiver- CometChatConstants.RECEIVER_TYPE_USER (user) or CometChatConstants.RECEIVER_TYPE_GROUP (group) | Required |
TextMessage
object which includes all information related to the sent message.
setMetadata
method and pass a JSONObject
to it.
sendMediaMessage()
method and pass a MediaMessage
object to it.
MediaMessage
class constructor takes the following parameters:
Parameter | Description |
---|---|
receiverId | The UID or GUID of the recipient |
file | The file object to be sent |
messageType | The type of the message that needs to be sent which in this case can be: 1. CometChatConstants.MESSAGE_TYPE_IMAGE (image) 2. CometChatConstants.MESSAGE_TYPE_VIDEO (video) 3. CometChatConstants.MESSAGE_TYPE_AUDIO (audio) 4. CometChatConstants.MESSAGE_TYPE_FILE (file) |
receiverType | The type of the receiver to whom the message is to be sent i.e CometChatConstants.RECEIVER_TYPE_USER (user) or CometChatConstants.RECEIVER_TYPE_GROUP (group) |
MediaMessage
object which includes all information related to the sent 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
.
setMetadata
method and pass a JSONObject
to it.
sendCustomMessage()
method.
The sendCustomMessage()
methods takes an object of the CustomMessage
which can be obtained using the below constructor.
custom
.
The parameters involved are:
receiverId
- Unique id of the user or group to which the message is to be sent.receiverType
- Type of the receiver i.e user or groupcustomType
- custom message type that you need to setcustomData
- The data to be passed as the message in the form of a JSONObject.CustomMessage
class to set a specific type for the custom message. This can be achieved using the setSubtype()
method.
Once the object of CustomMessage
class is ready you can send the custom message using the sendCustomMessage()
method.
CustomMessage
class.