Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Periodically delete server-side messages

Enable or disable periodic server-side message deletion for a conversation with OpenIM iOS SDK.

Copy

Invoke setConversationIsMsgDestruct:isMsgDestruct:onSuccess:onFailure: to enable or disable the periodic automatic deletion policy for server-stored historical messages in a specified conversation:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation ID.
isMsgDestructBOOLYesWhether to enable periodic server-side message deletion. Pass YES to enable, or NO to disable.

Code example

[[OIMManager manager] setConversationIsMsgDestruct:@"c2c_user1002"
                                     isMsgDestruct:YES
                                         onSuccess:^(NSString * _Nullable data) {
                                             NSLog(@"setConversationIsMsgDestruct success");
                                         }
                                         onFailure:^(NSInteger code, NSString *message) {
                                             NSLog(@"setConversationIsMsgDestruct failed: %ld %@", (long)code, message);
                                         }];

Return value

The onSuccess callback returns confirmation when the operation succeeds.

State changes after the call

  1. Local state update: The conversation's isMsgDestruct attribute is updated locally and synchronized with the backend.
  2. Event notification: Updated conversation properties are broadcast via the onConversationChanged: delegate callback. Match items by conversationID to update local state and toggle controls.
  3. Re-query calibration: This switch controls server-side message retention, which functions independently from client-side burn-after-reading. The actual duration before deletion is configured using Set the server-side message deletion period. For conversation listener setup, refer to Retrieve conversation list.