Documentation Index
Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Key Classes | BaseMessage, CometChatException |
| Key Methods | CometChat.deleteMessage() |
| Listener Events | onMessageDeleted |
| Prerequisites | SDK initialized, user logged in |
deletedAt (timestamp), deletedBy (user who deleted)- Adding a listener to receive real-time message deletes when your app is running.
- Calling a method to retrieve missed message delete events when your app was not running.
Delete a Message
In other words, as a sender, how do I delete a message? UsedeleteMessage() with the message ID of the message to be deleted.
| Parameter | Type | Description |
|---|---|---|
messageId | int | The ID of the message to delete. |
onSuccess | Function(BaseMessage) | Callback triggered on success with the deleted message object. |
onError | Function(CometChatException) | Callback triggered on error with exception details. |
- Delete Message
Response
Response
On Success — A
BaseMessage object with deletedAt and deletedBy fields set:BaseMessage Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
id | number | Unique message ID | 1234 |
metadata | object | Custom metadata attached to the message | {} |
receiver | object | Receiver user object | See below ↓ |
editedBy | string | UID of the user who edited the message | null |
conversationId | string | Unique conversation identifier | "cometchat-uid-1_user_cometchat-uid-2" |
sentAt | number | Epoch timestamp when the message was sent | 1745554729 |
receiverUid | string | UID of the receiver | "cometchat-uid-2" |
type | string | Type of the message | "text" |
readAt | number | Epoch timestamp when the message was read | 0 |
deletedBy | string | UID of the user who deleted the message | "cometchat-uid-1" |
deliveredAt | number | Epoch timestamp when the message was delivered | 1745554750 |
deletedAt | number | Epoch timestamp when the message was deleted | 1745554800 |
replyCount | number | Number of replies to this message | 0 |
sender | object | Sender user object | See below ↓ |
receiverType | string | Type of the receiver | "user" |
editedAt | number | Epoch timestamp when the message was edited | 0 |
parentMessageId | number | ID of the parent message (for threads) | 0 |
readByMeAt | number | Epoch timestamp when read by the current user | 0 |
category | string | Message category | "message" |
deliveredToMeAt | number | Epoch timestamp when delivered to the current user | 0 |
updatedAt | number | Epoch timestamp when the message was last updated | 1745554800 |
unreadRepliesCount | number | Count of unread replies | 0 |
quotedMessageId | number | ID of the quoted message | null |
sender Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique identifier of the sender | "cometchat-uid-1" |
name | string | Display name of the sender | "Andrew Joseph" |
link | string | Profile link | null |
avatar | string | Avatar URL | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp" |
metadata | object | Custom metadata | {} |
status | string | Online status | "online" |
role | string | User role | "default" |
statusMessage | string | Status message | null |
tags | array | User tags | [] |
hasBlockedMe | boolean | Whether this user has blocked the current user | false |
blockedByMe | boolean | Whether the current user has blocked this user | false |
lastActiveAt | number | Epoch timestamp of last activity | 1745554700 |
receiver Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique identifier of the receiver | "cometchat-uid-2" |
name | string | Display name of the receiver | "George Alan" |
link | string | Profile link | null |
avatar | string | Avatar URL | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp" |
metadata | object | Custom metadata | {} |
status | string | Online status | "offline" |
role | string | User role | "default" |
statusMessage | string | Status message | null |
tags | array | User tags | [] |
hasBlockedMe | boolean | Whether this user has blocked the current user | false |
blockedByMe | boolean | Whether the current user has blocked this user | false |
lastActiveAt | number | Epoch timestamp of last activity | 1745550000 |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_CHAT_API_FAILURE" |
message | string | Human-readable error message | "The message could not be deleted." |
details | string | Additional technical details | "Ensure the message ID is valid and you have permission to delete this message." |
deletedAt (timestamp) and deletedBy (UID of deleter) fields set.
Relevant fields to access on the returned message:
| Field | Property | Return Type | Description |
|---|---|---|---|
| deletedAt | deletedAt | int | Timestamp when the message was deleted |
| deletedBy | deletedBy | String | UID of the user who deleted the 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 |
Real-time Message Delete Events
In other words, as a recipient, how do I know when someone deletes a message when my app is running? UseonMessageDeleted in MessageListener to receive real-time delete events.
- Dart
onMessageDeleted callback receives a BaseMessage object with the deletedAt and deletedBy fields set.
Relevant fields to access on the returned message:
| Field | Property | Return Type | Description |
|---|---|---|---|
| deletedAt | deletedAt | int | Timestamp when the message was deleted |
| deletedBy | deletedBy | String | UID of the user who deleted the message |
Missed Message Delete Events
In other words, as a recipient, how do I know if someone deleted a message when my app was not running? When you retrieve the list of previous messages, for the messages that were deleted, thedeletedAt and the deletedBy fields will be set. Also, for example, if 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 an 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-deletedactionOn- 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.
You must be the message sender or a group admin/moderator to delete a message.
Next Steps
Edit Message
Modify sent messages before deletion
Send Message
Send text, media, and custom messages
Receive Messages
Handle incoming messages in real-time
Flag a Message
Report inappropriate messages