SDKsAndroid
Delete all messages from a user in a group chat
Delete every message sent by a specified user in a group chat with the Android SDK.
Group owners and administrators can clear every historical message sent by a designated member in a group chat. This is commonly used to remove spam, moderate rule violations, or ban abusive accounts across a group conversation.
Code example
String conversationID = "g_group_123";
String targetUserID = "user_spammer";
OpenIMClient.getInstance().messageManager.deleteUserAllMessagesInConv(
conversationID,
targetUserID,
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Deletion request processed successfully
}
@Override
public void onError(int code, String error) {
// Failed to delete user messages (e.g. insufficient permissions)
}
}
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | String | Yes | Globally unique ID of the target group conversation. Group conversations only. |
targetUserID | String | Yes | User ID of the member whose messages should be cleared. |
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the server has executed the purge across the specified group conversation. - Asynchronous event delivery: All online group members receive an event via
OnAdvanceMsgListener.onDeleteUserAllMsgsInConv:
@Override
public void onDeleteUserAllMsgsInConv(DeleteUserAllMsgsListenerMsg event) {
// Filter by event.getConversationID() and event.getUserID()
// Remove all messages sent by this user from the local timeline
}Group members filter messages by conversationID and sendID == targetUserID, removing all matching bubbles from their active UI timeline.
- Re-query calibration: If UI state diverges after reconnecting, reload the message history using Load older messages.
For complete listener registration and lifecycle management, see Receive messages.
Was this page helpful?