Schedule server message deletion
Enable, disable, and configure scheduled server-side message retention for a specific conversation.
Configure scheduled server-side message destruction policies for a specific conversation. When enabled, the server automatically purges historical messages that exceed the configured retention window. This is a server retention strategy, distinct from client-side burn-after-reading.
Code example
ConversationReq request = new ConversationReq();
request.setMsgDestruct(true);
request.setMsgDestructTime(3600);
OpenIMClient.getInstance().conversationManager.setConversation(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Destruction settings saved successfully.
}
@Override
public void onError(int code, String error) {
// code and error describe the failure.
}
},
conversationID,
request
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
conversationID | String | Yes | Target conversation identifier. |
request | ConversationReq | Yes | Conversation configuration request object. |
Request attributes
| Property | Type | Description |
|---|---|---|
isMsgDestruct | boolean | Enables or disables scheduled server-side message purging. Pass false to disable. |
msgDestructTime | int | Retention interval in seconds, such as 3600. |
Return value
The successful callback indicates that the server recorded the destruction policy. This configuration applies strictly to server-side history retention; to destroy messages immediately upon viewing, see Enable or disable burn after reading.
State changes after the call
Once the policy takes effect, the SDK triggers the OnConversationListener.onConversationChanged event. Locate the conversation by conversationID and update its isMsgDestruct and msgDestructTime fields. For complete listener registration details, see Get the conversation list.
Was this page helpful?