Browse SDKs · uni-app / uni-app x
SDKsuni-app

Delete messages in a batch

OpenIM uni-app / uni-app x SDK guide for Delete messages in a batch.

Copy

deleteMessages() is Commercial and batch-deletes explicitly selected messages from one conversation.

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation containing the messages.
clientMsgIDsstring[]YesMessage IDs; all IDs in one request must belong to this conversation.
IsSyncbooleanYesWhether to synchronize deletion to this account's other clients. The capital I is part of the field name.
import { deleteMessages, off, onMsgDeleted } from '@/uni_modules/unix-openim-sdk'

const deletedSubscription = onMsgDeleted((message) => {
  if (message == null) return
  removeMessage(resolveConversationID(message), message.clientMsgID)
})
await deleteMessages({ conversationID, clientMsgIDs: selectedMessageIDs, IsSync: true })

function removeMessageDeletedListener() {
  off(deletedSubscription)
}

IsSync: false removes current-device and current-account server records; true also requests synchronization to other clients. It does not remove copies belonging to other conversation members and does not create a revoked-message notice.

Promise completion does not prove that every client received the event. Public onMsgDeleted belongs to this page and provides OpenIMMessageItem | null; resolve its conversation and remove by clientMsgID idempotently. Remove the listener on logout/account change and reconcile with history when necessary.