logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Recall messages


Overview

The ZIM SDK supports the ability to recall messages sent by the local end in one-on-one or group chat sessions, as well as the ability for the group owner to recall messages sent by others in a group chat session.

This document describes how to use the interfaces of the ZIM SDK to recall specified messages in a particular session.

Note

If the ZIM SDK version used by the message recipient is lower than 2.5.0, the following three situations may occur when a message is recalled:

  • If the user is online and receives the message, they will still see the message.
  • If the user is offline and receives the message, they will not see the message if they do not actively query the message history after logging in.
  • If the user is offline and receives the message, they will see the message with the message type displayed as "unknown" if they actively query the message history after logging in.

Implementation process

The In-app Chat SDK supports recalling a specified message in a session. Developers can call ZIMMessageRevokeConfig to configure advanced attributes for recalling messages.

Recalling a message sent from Client A to Client B is used as an example:

  1. Client A and Client B create their In-app Chat instances and register the messageRevokeReceived callback API listened for by on to receive message recalling notifications.
  2. Client A and Client B log in to the In-app Chat service.
  3. Client A sends one-to-one messages to Client B and wants to recall a message. (1) Client A calls the revokeMessage API and introduces the message and config parameters to recall the specified message. (2) Client A obtains the recalling result through the ZIMMessageRevokedResult callback API. (3) Client B obtains message recalling notifications through the messageRevokeReceived callback API.

Configure the function of listening for message recalling

After successful login, users can listen for message recalling notifications through the messageRevokeReceived callback API. After other users recall a message, the SDK can obtain related information of the recalled message, including the recalling time and recalled message type.

Recall messages

By default, users can call the revokeMessage API to recall a message sent in 2 minutes. The recalling result will be sent to the user through the ZIMMessageRevokedResult callback API.

Note
  • To enable the group owner to revoke messages from other users, please integrate ZIM SDK version 2.9.0 or above.
  • Currently, ZIM SDK supports revoking messages within 2 minutes by default. If you need to modify the configuration (up to 24 hours maximum), please contact ZEGOCLOUD technical support.
Sample code
// Recall the specified message in a session.
var config = {
    revokeExtendedData: "test"
};

zim.revokeMessage(message, config)
    .then(function ({ message }) {
        // The operation is successful. The recalled message is updated on the local message list.
    })
    .catch(function (err) {
        // The operation fails.
    });
1
Copied!

Previous

Forward messages

Next

Read receipts