While editing a message is straightforward, receiving events for edited messages with CometChat has two parts: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.
- Adding a listener for real-time edits when your app is running
- Fetching missed edits when your app was offline
Edit a Message
UseeditMessage() with a TextMessage or CustomMessage object. Set the message ID using setId().
Add/Update Tags
UsesetTags() to update tags when editing. New tags replace existing ones.
- Text Message (TypeScript)
- Text Message (JavaScript)
- Custom Message (TypeScript)
- Custom Message (JavaScript)
editMessage().
- TypeScript
- JavaScript
editedAt (timestamp) and editedBy (UID of editor) fields set.
The editMessage() method returns a BaseMessage object (or a subclass like TextMessage).
Relevant fields to access on the returned message:
| Field | Getter | Return Type | Description |
|---|---|---|---|
| editedAt | getEditedAt() | number | Timestamp when the message was edited |
| editedBy | getEditedBy() | string | UID of the user who edited the message |
| User | Conversation Type | Edit Capabilities |
|---|---|---|
| Message Sender | One-on-One Conversation | Messages they have sent. |
| Message Sender | Group Conversation | Messages they have sent. |
| Group Owner | Group Conversation | All messages in the group. |
| Group Moderator | Group Conversation | All messages in the group. |
Real-time Message Edit Events
UseonMessageEdited in MessageListener to receive real-time edit events.
- TypeScript
- JavaScript
onMessageEdited callback receives a BaseMessage object with the editedAt and editedBy fields set.
Relevant fields to access on the returned message:
| Field | Getter | Return Type | Description |
|---|---|---|---|
| editedAt | getEditedAt() | number | Timestamp when the message was edited |
| editedBy | getEditedBy() | string | UID of the user who edited the message |
Missed Message Edit Events
When fetching message history, edited messages haveeditedAt and editedBy fields set. Additionally, an Action message is created when a message is edited.
The Action object contains:
action—editedactionOn— Updated message objectactionBy— User who edited the messageactionFor— Receiver (User/Group)
You must be the message sender or a group admin/moderator to edit a message.
Next Steps
Delete a Message
Remove messages from conversations
Send Messages
Send text, media, and custom messages
Threaded Messages
Organize conversations with message threads
Receive Messages
Listen for incoming messages in real time