SDKsReact Native
Search friends
Search friends by keyword across user ID, nickname, and remark using the OpenIM React Native SDK.
Search friend records by keyword across specified fields. Trim whitespace before querying; the search evaluates the first non-empty string in keywordList:
const friends = await OpenIMSDK.searchFriends({
keywordList: [keyword.trim()],
isSearchUserID: true,
isSearchNickname: true,
isSearchRemark: true,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
keywordList | string[] | Yes | Array of keyword strings; the first non-empty item is used for search. |
isSearchUserID | boolean | Yes | Whether to match against user IDs. |
isSearchNickname | boolean | Yes | Whether to match against friend nicknames. |
isSearchRemark | boolean | Yes | Whether to match against friend remarks. |
Return value
Resolves to an array of SearchedFriendsInfo[]. Each item includes friend attributes along with relationship: 0 indicates a blacklisted relation, while 1 indicates a friendship relation. Use userID as the unique key to identify and display search results.
Was this page helpful?