Browse SDKs · Android
Platform
SDKsAndroid

Update friend information

Update remarks, pinned status, or custom extensions for specified friends using updateFriendsReq().

Copy

Modify friend relationship attributes, including setting remark aliases, pinning friends in the contacts list, and updating custom extension fields.

Code example

UpdateFriendsReq request = new UpdateFriendsReq();
request.setFriendUserIDs(new String[] { friendUserID });
request.setRemark(remark.trim());

OpenIMClient.getInstance().friendshipManager.updateFriendsReq(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Friend information updated successfully
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    },
    request
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
requestUpdateFriendsReqYesRequest payload containing updated friend attributes.

Request attributes

FieldTypeDescription
friendUserIDsString[]Array of target friend user IDs. When providing multiple IDs, specified field values overwrite existing values across all targets.
remarkStringRemark alias set by the authenticated user for the friend.
isPinnedbooleanWhether to pin the friend at the top of the contacts list.
exStringCustom friend relationship metadata.

Return value

The successful callback indicates that the server persisted the updated friend information.

State changes after the call

Once the updates take effect, the SDK dispatches the onFriendInfoChanged(FriendInfo friend) event via OnFriendshipListener. Locate the cached friend record using userID and update its modified properties. For complete listener registration details, see Get the friend list.