Browse SDKs · React Native
Platform
SDKsReact Native

Search friends

Search friends by keyword across user ID, nickname, and remark using the OpenIM React Native SDK.

Copy

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

ParameterTypeRequiredDescription
keywordListstring[]YesArray of keyword strings; the first non-empty item is used for search.
isSearchUserIDbooleanYesWhether to match against user IDs.
isSearchNicknamebooleanYesWhether to match against friend nicknames.
isSearchRemarkbooleanYesWhether 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.