SDKsuni-app / uni-app x
Search friends
Search the authenticated user’s friends by user ID, nickname, or remark.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
keywordList | string[] | Yes | An array of search strings. The SDK utilizes the first non-empty keyword. |
isSearchUserID | boolean | Yes | Whether to match against friend user IDs. |
isSearchNickname | boolean | Yes | Whether to match against friend account nicknames. |
isSearchRemark | boolean | Yes | Whether 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.
Was this page helpful?