SDKsiOS
Delete a message
Delete one message from a specified conversation for the current account with OpenIM iOS SDK.
Invoke deleteMessage:clientMsgID:onSuccess:onFailure: on OIMManager to delete a single historical message in a specified conversation for the current logged-in user:
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 deletion request completion. |
onFailure | OIMFailureCallback | Yes | Failure callback returning error code code and descriptive message msg. |
Code example
[[OIMManager manager] deleteMessage:conversationID
clientMsgID:clientMsgID
onSuccess:^(NSString * _Nullable data) {
// Deletion succeeded; remove message bubble from local UI
[self removeMessageFromUI:clientMsgID];
}
onFailure:^(NSInteger code, NSString * _Nullable msg) {
// Handle deletion failure
}];Return value
The onSuccess callback confirms that the deletion request was processed for the current account.
State changes after the call
- Current account visibility: This operation removes the message from the current account's local storage and server records. It does not delete copies held by other conversation participants and does not render a "message revoked" placeholder.
- Client merge key: The merge key is
clientMsgID(scoped toconversationIDwhen managing multi-conversation stores). - Revocation vs batch deletion: If you need to retract a message so that all members see a revocation notice, see Revoke a message. To delete multiple messages simultaneously or synchronize deletion across multiple devices of the current account, see Delete messages in batches.
Was this page helpful?