SDKsAndroid
Update friend information
Update remarks, pinned status, or custom extensions for specified friends using updateFriendsReq().
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
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
request | UpdateFriendsReq | Yes | Request payload containing updated friend attributes. |
Request attributes
| Field | Type | Description |
|---|---|---|
friendUserIDs | String[] | Array of target friend user IDs. When providing multiple IDs, specified field values overwrite existing values across all targets. |
remark | String | Remark alias set by the authenticated user for the friend. |
isPinned | boolean | Whether to pin the friend at the top of the contacts list. |
ex | String | Custom 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.
Was this page helpful?