Browse SDKs · iOS
Platform
SDKsiOS

Update friend information

Update iOS friend remarks, pinned status, or extension fields.

Copy

Update friend remarks, pinned statuses, or custom relationship extension attributes using updateFriends:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
reqOIMUpdateFriendsReq *YesRequest object containing target friend user IDs and attributes to update.

Request attributes (OIMUpdateFriendsReq)

ParameterTypeRequiredDescription
friendUserIDsNSArray<NSString *> *YesList of friend user IDs. Modifications apply uniformly to every listed friend.
remarkNSString *NoCustom alias or remark name for the friend.
isPinnedBOOLNoWhether to pin the friend in contact lists.
exNSString *NoCustom 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 userID as the unique entity key.
  • Asynchronous event listening: Multi-device clients and local listeners observe updates via onFriendInfoChanged: in OIMFriendshipListener (see Retrieve the friend list by page).
  • Re-query calibration: To reconcile contact data snapshots, invoke Retrieve specified friends.