SDKsReact Native
Search friends
Search the current user's friends with the OpenIM React Native SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
keywordList | string[] | Yes | Search keywords. The current request uses the first non-empty keyword. |
isSearchUserID | boolean | Yes | Whether to match user IDs. |
isSearchNickname | boolean | Yes | Whether to match friend nicknames. |
isSearchRemark | boolean | Yes | Whether 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.
Was this page helpful?