tencent cloud

All product documents
Chat
JavaScript
Last updated: 2025-01-07 15:20:40
JavaScript
Last updated: 2025-01-07 15:20:40

Feature Overview

This feature is used to recall a one-to-one or group message. After the message is recalled successfully, the value of its isRevoked attribute will be true.
Note:
1. The time limit for message recall is two minutes by default. You can log in to the Chat Console to change this limit.
2. Call the getMessageList API to pull a recalled message from roaming one-to-one or group messages. The receiver needs to properly display the recalled message based on the isRevoked attribute of the message object, for example, as "The other party recalled a message" in a one-to-one conversation or as "XXX recalled a message" in a group conversation.

UI Display








Recall a Message

API
chat.revokeMessage(message);
Parameters
Name
Type
Description
message
Message
Message instance
Return value
Promise
Examples
// Recall a message
let promise = chat.revokeMessage(message);
promise.then(function(imResponse) {
// Message recalled successfully
}).catch(function(imError) {
// Failed to recall the message
console.warn('revokeMessage error:', imError);
});
// Received a message recall notification
chat.on(TencentCloudChat.EVENT.MESSAGE_REVOKED, function(event) {
// event.name - TencentCloudChat.EVENT.MESSAGE_REVOKED
// event.data - An array that stores Message objects - [Message]
// The `isRevoked` attribute value of each Message object is `true`.
});
// Encountered the recalled message while getting the list of messages in the conversation
let promise = chat.getMessageList({conversationID: 'C2Ctest', count: 15});
promise.then(function(imResponse) {
const messageList = imResponse.data.messageList; // Message list
messageList.forEach(function(message) {
if (message.isRevoked) {
// Process the recalled message
} else {
// Process ordinary messages
}
});
});

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon