SDKsiOS
Update friend information
Update iOS friend remarks, pinned status, or extension fields.
Update friend remarks, pinned statuses, or custom relationship extension attributes using updateFriends:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
req | OIMUpdateFriendsReq * | Yes | Request object containing target friend user IDs and attributes to update. |
Request attributes (OIMUpdateFriendsReq)
| Parameter | Type | Required | Description |
|---|---|---|---|
friendUserIDs | NSArray<NSString *> * | Yes | List of friend user IDs. Modifications apply uniformly to every listed friend. |
remark | NSString * | No | Custom alias or remark name for the friend. |
isPinned | BOOL | No | Whether to pin the friend in contact lists. |
ex | NSString * | No | Custom extension string, replacing the existing field entirely. |
Code example
OIMUpdateFriendsReq *req = [OIMUpdateFriendsReq new];
req.friendUserIDs = @[@"user_b"];
req.remark = @"Alex";
req.isPinned = YES;
[[OIMManager manager] updateFriends:req
onSuccess:^(NSString *data) {
[friendStore updateRemark:req.remark forUserID:@"user_b"];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"updateFriends failed: %ld %@", (long)code, message);
}];The ex attribute replaces the previous string in its entirety. Preserve existing application JSON key-value pairs before writing.
Return value
The onSuccess callback signifies that OpenIMServer processed the update request.
State changes after the call
- Local state merge: Merge updated friend attributes using
userIDas the unique entity key. - Asynchronous event listening: Multi-device clients and local listeners observe updates via
onFriendInfoChanged:inOIMFriendshipListener(see Retrieve the friend list by page). - Re-query calibration: To reconcile contact data snapshots, invoke Retrieve specified friends.
Was this page helpful?