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

Search friends

Search current friends by ID, nickname, or remark.

Copy

searchFriends() searches only current friends, not every server user.

Use the boolean fields to choose which friend attributes are matched. The recommended flow uses one trimmed, non-empty keyword; reject an empty search before calling the SDK.

Parameters

ParameterTypeRequiredDescription
keywordListstring[]YesSearch keywords. The current flow uses the first non-empty keyword.
isSearchUserIDbooleanYesWhether to match friend user IDs.
isSearchNicknamebooleanYesWhether to match friend nicknames.
isSearchRemarkbooleanYesWhether to match remarks set by the current user.
import { searchFriends } from '@/uni_modules/unix-openim-sdk'

const result = await searchFriends({
  keywordList: ['Alice'],
  isSearchUserID: true,
  isSearchNickname: true,
  isSearchRemark: true,
})
renderFriends(result?.friends ?? [])

The Promise resolves directly to OpenIMFriendListResult or null; friends contains OpenIMFriendUserItem[]. See Get the friend list for friend fields.

Search results are a snapshot for the current query. They do not modify friend profiles or server indexes and must not replace the full friend list. Link each result to existing friend state by userID and continue merging friend events. Use Get specified friend information when the target friend IDs are already known.