Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Schedule server message deletion

Enable, disable, and configure scheduled server-side message retention for a specific conversation.

Copy

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

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
conversationIDStringYesTarget conversation identifier.
requestConversationReqYesConversation configuration request object.

Request attributes

PropertyTypeDescription
isMsgDestructbooleanEnables or disables scheduled server-side message purging. Pass false to disable.
msgDestructTimeintRetention 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.