SDKsiOS
Delete a local message
Delete one message from the current device only with OpenIM iOS SDK.
Invoke deleteMessageFromLocalStorage:clientMsgID:onSuccess:onFailure: on OIMManager to remove a single message from the current device's local database without contacting the server or affecting other devices:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target conversation identifier. |
clientMsgID | NSString * | Yes | Client message ID of the message to delete. |
onSuccess | OIMSuccessCallback | Yes | Success callback confirming local deletion. |
onFailure | OIMFailureCallback | Yes | Failure callback returning error code code and descriptive message msg. |
Code example
[[OIMManager manager] deleteMessageFromLocalStorage:conversationID
clientMsgID:clientMsgID
onSuccess:^(NSString * _Nullable data) {
// Local deletion succeeded; update message list UI
[self removeMessageFromUI:clientMsgID];
}
onFailure:^(NSInteger code, NSString * _Nullable msg) {
// Handle local deletion failure
}];Return value
The onSuccess callback confirms that the message was removed from local storage on the current device.
State changes after the call
- Local-only removal: This method deletes the record from the current device's SQLite database only. Server roaming records remain intact; if the user clears app data or rebuilds the local database, the message may be synchronized again.
- No remote events: This is a purely local operation that does not emit events to other devices or conversation participants. The client merge key is
clientMsgIDscoped toconversationID. To delete a message across both local storage and the server, see Delete a message.
Was this page helpful?