Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Delete friend

Remove a user from the current account’s friend relationships.

Copy

Remove an active friend relationship for the signed-in account:

Code example

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

const request: DeleteFriendReq = {
  userID: friendUserID,
};
await sdk.deleteFriend(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesTarget user identifier to remove from friends.

Return value

Returns a Promise that resolves to void upon deletion.

State changes after the call

Promise resolution indicates that the deletion request was processed on the server. Remove the record from your local friend directory matched by friendUserID (matching the target userID). Real-time event handling is detailed in Paginate friend list. Deleting a friend does not block the user or delete chat history; to block a user, see Add user to blocklist.