receiverType
and the UID/GUID specified for the message. A message can belong to either of the below types:
parentMessageId
must be set for the message to indicate that the message to be sent needs to be a part of the thread with the specified parentMessageId
.
This can be achieved using the parentMessageId
property provided by the object of the TextMessage
, MediaMessage
, and CustomMessage
class. The id specified in the parentMessageId
property maps the message sent to the particular thread.
Example to Send a Text Message in a thread in a user conversation.
parentMessageId
100.
Similarly, using the parentMessageId
property, Media and Custom Messages can be sent in threads too.
CometChatMessageDelegate
class provided by the SDK.
In order to receive incoming messages, you must add protocol conformance CometChatMessageDelegate as Shown in the below code example. The only thing that needs to be checked is if the received message belongs to the active thread. This can be done using the parentMessageId
field of the message object.
MessagesRequest
class. In order to get an object of the MessagesRequest
class, you need to use the MessagesRequestBuilder
class. and use the setParentMessageId()
method of the MessagesRequestBuilder
to inform the SDK that you only need the messages belonging to the thread with the specified parentMessageId.
Once you have the object of the MessagesRequest
class, you need to call the fetchPrevious()
method to get the latest messages in the thread. In one integration, a maximum of 100 messages can be fetched. If you wish to fetch the next set of messages, you need to call the fetchPrevious()
method again on the same object.
MessagesRequest
, the threaded messages by default will be a part of the list of messages received. In order to exclude the threaded messages from the list of user/group messages, you need to use the hideReplies()
method of the MessagesRequestBuilder
class. This method takes a boolean argument which when set to true excludes the messages belonging to threads from the list of messages.
cometchat-uid-1
excluding all the threaded messages belonging to the same conversation.