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

Find messages by ID

Retrieve specific local messages by conversation ID and client message IDs.

Copy

When navigating to messages from search hits, quote reply references, or push notification intents, retain both conversationID and clientMsgID. Invoke findMessageList() with an array of query descriptors to look up exact message records stored in the local database.

Parameters

The method accepts an array of query objects, each scoped to a single conversation:

ParameterTypeRequiredDescription
conversationIDstringYesIdentifier of the conversation containing the target messages.
clientMsgIDListstring[]YesArray of clientMsgID values to locate within that conversation.

Code example

import { findMessageList } from '@/uni_modules/unix-openim-sdk'

const result = await findMessageList([{
  conversationID: conversationID,
  clientMsgIDList: [clientMsgID],
}])

if (
  result != null &&
  result.findResultItems.length > 0 &&
  result.findResultItems[0].messageList.length > 0
) {
  const targetMessage = result.findResultItems[0].messageList[0]
  showMessage(targetMessage)
}

Return value

The Promise resolves with an OpenIMFindMessageResult | null object. The totalCount property indicates total matches found across all requested conversations. The findResultItems array (OpenIMFindResultItem[]) groups returned messages by conversation, providing conversationID, display metadata, messageCount, and messageList (OpenIMMessageItem[]).

A single invocation can query multiple conversations concurrently. Do not assume positional correspondence between the input array and findResultItems; always match entries using conversationID and locate individual items using clientMsgID.

State changes after the call

If a message has not yet synchronized locally, was permanently deleted, or was never created, the returned list for that entry is empty. This call performs a read-only query and does not emit message events.