Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Update friend profile

Modify a friend’s remark note, pinned status, or custom relationship metadata.

Copy

Update friend information one friend at a time. Include only the fields you wish to change. The ex parameter is an opaque replacement string; the engine does not automatically merge existing JSON attributes:

Code example

import sdk, { UpdateFriendReq } from '@openimsdk/imsdk';

const request: UpdateFriendReq = {
  userID: friendUserID,
  remark: remark.trim(),
  pinned: true,
};
await sdk.updateFriend(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesTarget friend's user identifier.
remarkstringNoPrivate remark note for this friend.
pinnedbooleanNoWhether to pin this friend in contact listings.
exstringNoUpdated complete relationship metadata string.

Return value

Returns a Promise that resolves to void upon updating the friend record on the server.

State changes after the call

Resolving the Promise confirms that the request reached the server; it does not guarantee that asynchronous friend events have arrived. When EventOnFriendInfoChanged arrives, update local state keyed by friendUserID (matching the target userID). For listener setup, see Paginate friend list.