Browse SDKs · iOS
Platform
SDKsiOS

Delete a message

Delete one message from a specified conversation for the current account with OpenIM iOS SDK.

Copy

Invoke deleteMessage:clientMsgID:onSuccess:onFailure: on OIMManager to delete a single historical message in a specified conversation for the current logged-in user:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
clientMsgIDNSString *YesClient message ID of the message to delete.
onSuccessOIMSuccessCallbackYesSuccess callback confirming deletion request completion.
onFailureOIMFailureCallbackYesFailure 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

  1. 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.
  2. Client merge key: The merge key is clientMsgID (scoped to conversationID when managing multi-conversation stores).
  3. 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.