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

Search friends

Search the authenticated user’s friends by user ID, nickname, or remark.

Copy

Invoke searchFriends() to search through the authenticated user's local friend records using matching criteria. The SDK consumes the first non-empty keyword in the array; trim whitespace and enable at least one search dimension.

Parameters

ParameterTypeRequiredDescription
keywordListstring[]YesAn array of search strings. The SDK utilizes the first non-empty keyword.
isSearchUserIDbooleanYesWhether to match against friend user IDs.
isSearchNicknamebooleanYesWhether to match against friend account nicknames.
isSearchRemarkbooleanYesWhether to match against custom friend remarks.

Code example

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

const result = await searchFriends({
  keywordList: [keyword.trim()],
  isSearchUserID: true,
  isSearchNickname: true,
  isSearchRemark: true,
})
const matchedFriends = result?.friends ?? []

Return value

The Promise resolves with an OpenIMFriendListResult | null object, containing matched friends in the friends property as OpenIMFriendUserItem[]. For field definitions, see Get the friend list.

State changes after the call

Search results represent a transient filtered subset. Map items by userID rather than overwriting your primary friend roster with search results. This method is read-only and does not trigger friend events.