Browse SDKs · React Native
SDKsReact Native

Search friends

Search the current user's friends with the OpenIM React Native SDK.

Copy

Call searchFriends() to search the current user's friends. Trim leading and trailing whitespace before submitting a search. The current request uses the first non-empty value in keywordList.

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

Parameter description

ParameterTypeRequiredDescription
keywordListstring[]YesSearch keywords. The current request uses the first non-empty keyword.
isSearchUserIDbooleanYesWhether to match user IDs.
isSearchNicknamebooleanYesWhether to match friend nicknames.
isSearchRemarkbooleanYesWhether to match friend remarks.

The method returns SearchedFriendsInfo[]. Each item contains friend fields and relationship: 0 indicates a blocklist relationship and 1 indicates a friendship.