Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Set the server-side message deletion period

Set the periodic deletion interval for a conversation’s server-side messages with OpenIM iOS SDK.

Copy

Invoke setConversationMsgDestructTime:msgDestructTime:onSuccess:onFailure: to configure the periodic retention cycle for messages stored on the server for a specified conversation:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation ID.
msgDestructTimeNSIntegerYesDuration before messages are deleted on the server, specified in seconds.

Code example

[[OIMManager manager] setConversationMsgDestructTime:@"c2c_user1002"
                                     msgDestructTime:86400
                                           onSuccess:^(NSString * _Nullable data) {
                                               NSLog(@"setConversationMsgDestructTime success");
                                           }
                                           onFailure:^(NSInteger code, NSString *message) {
                                               NSLog(@"setConversationMsgDestructTime 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 msgDestructTime 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 refresh local cache and settings displays.
  3. Re-query calibration: This property defines the time interval before server messages are pruned. Whether automatic destruction is active depends on the toggle configured in Periodically delete server-side messages. For conversation listener setup, refer to Retrieve conversation list.