SDKsiOS
Search friends
Search the current user’s friends with OpenIM iOS SDK.
Search local friend records matching specified keywords using searchFriends:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
param | OIMSearchFriendsParam * | Yes | Search parameter object specifying keywords and matching scopes. If keywords are empty, clear search UI results immediately. |
Search parameter attributes (OIMSearchFriendsParam)
| Parameter | Type | Required | Description |
|---|---|---|---|
keywordList | NSArray<NSString *> * | Yes | List of search keyword strings. |
isSearchUserID | BOOL | No | Whether to match keywords against user IDs. |
isSearchNickname | BOOL | No | Whether to match keywords against friend nicknames. |
isSearchRemark | BOOL | No | Whether to match keywords against friend remarks. |
Code example
OIMSearchFriendsParam *param = [OIMSearchFriendsParam new];
param.keywordList = @[keyword];
param.isSearchUserID = YES;
param.isSearchNickname = YES;
param.isSearchRemark = YES;
[[OIMManager manager] searchFriends:param
onSuccess:^(NSArray<OIMSearchFriendsInfo *> *items) {
[searchStore replaceResults:items];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"searchFriends failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback delivers an array of OIMSearchFriendsInfo matching the search criteria.
State changes after the call
- Local state merge: Search results form an isolated, ephemeral result set; do not overwrite the primary contact directory cache.
- Snapshot query: Friend searches capture a local database snapshot and do not emit friendship delegate events.
Was this page helpful?