Browse SDKs · iOS
Platform
SDKsiOS

Clear all local messages

Clear every local message for the current account with OpenIM iOS SDK.

Copy

Invoke deleteAllMsgFromLocalWithOnSuccess:onFailure: on OIMManager to wipe all historical messages for the current account from local SQLite database storage on the current device:

Parameters

ParameterTypeRequiredDescription
onSuccessOIMSuccessCallbackYesSuccess callback confirming local message storage has been cleared.
onFailureOIMFailureCallbackYesFailure callback returning error code code and descriptive message msg.

Code example

[[OIMManager manager] deleteAllMsgFromLocalWithOnSuccess:^(NSString * _Nullable data) {
    // Local messages cleared; reset in-memory message caches and UI
    [self resetAllMessageSnapshots];
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
    // Handle clearing failure
}];

Return value

The onSuccess callback confirms that all local message records on the device were deleted.

State changes after the call

  1. Local-only operation: This destructive operation removes records from the current device's local database only. Server roaming records remain intact; if the client synchronizes or re-queries history from the server, messages may be restored.
  2. No remote events: This method does not dispatch message deletion events to other devices or users. To clear messages across both the server and local storage simultaneously, see Clear all messages.