Recall a Message
Feature Description
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.Recall A Message
API
chat.revokeMessage(message);
Parameter
Name | Type | Description |
message | Message | Message instance |
Returned value
Promise
Sample
// Recall a messagelet promise = chat.revokeMessage(message);promise.then(function(imResponse) {// Message recalled successfully}).catch(function(imError) {// Failed to recall the messageconsole.warn('revokeMessage error:', imError);});
// Received a message recall notificationchat.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 conversationlet promise = chat.getMessageList({conversationID: 'C2Ctest', count: 15});promise.then(function(imResponse) {const messageList = imResponse.data.messageList; // Message listmessageList.forEach(function(message) {if (message.isRevoked) {// Process the recalled message} else {// Process ordinary messages}});});