Skip to main content

Recall Message

The IMKit SDK provides a default implementation for message recall and display logic. If the existing implementation doesn't meet your requirements, you can use the relevant APIs in IMCenter.

Recall a Message

You can call the following method in a custom page to recall a message. This method will simultaneously trigger updates in both the conversation list and chat UI.

Interface

IMCenter.getInstance().recallMessage(message, pushContent, callback)

Parameters

ParameterTypeDescription
messageMessageThe message to be recalled.
pushContentStringThe notification content displayed when a message is recalled.
callbackResultCallbackCallback for the recall result. The onSuccess callback returns a RecallNotificationMessage object (the gray bar replacement message), which you can display in your UI as needed.

Listen for Message Recall Events

You can add a listener to monitor recall events for received messages.

Sample Code

private RongIMClient.OnRecallMessageListener mRecallMessageListener =
new RongIMClient.OnRecallMessageListener() {
@Override
public boolean onMessageRecalled(
Message message, RecallNotificationMessage recallNotificationMessage) { }
};

IMCenter.getInstance().addOnRecallMessageListener(mRecallMessageListener);

// Remove when not needed
IMCenter.getInstance().removeOnRecallMessageListener(mRecallMessageListener);