deleteMessage()
method. This method takes the message ID of the message to be deleted.
onSuccess()
callback, you get an object of the BaseMessage
class, with the deletedAt
fieldset with the timestamp of the time the message was deleted. Also, the deletedBy
field is set. These two fields can be used to identify if the message is deleted while iterating through a list of messages.
By default, CometChat allows certain roles to delete a message.
User Role | Conversation Type | Deletion Capabilities |
---|---|---|
Message Sender | One-on-one Conversation | Messages they’ve sent |
Message Sender | Group Conversation | Messages they’ve sent |
Group Admin | Group Conversation | All messages in the group |
Group Moderator | Group Conversation | All messages in the group |
CometChatMessageDelegate
as Shown Below :
deletedAt
and the deletedBy
fields will be set. Also, for example, the total number of messages for a conversation are 100, and the message with message ID 50 was deleted. Now the message with id 50 will have the deletedAt
and the deletedBy
fields set whenever it is pulled from the history. Also, the 101st message will be and Action
message informing you that the message with id 50 has been deleted.
For the message deleted event, in the Action
object received, the following fields can help you get the relevant information-
action
- deleted
actionOn
- Updated message object which was deleted.actionBy
- User object containing the details of the user who has deleted the message.actionFor
- User/group object having the details of the receiver to which the message was sent.