Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Reject friend application

Decline a pending friend request from a designated user.

Copy

Decline an incoming friend application with an optional rejection reason note:

Code example

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

const request: HandleFriendApplicationReq = {
  userID: applicantUserID,
  handleMsg: rejectReason,
  status: ApprovalStatus.Rejected,
};
await sdk.handleFriendApplication(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesApplicant's user identifier.
handleMsgstringNoOptional rejection explanation note.
statusApprovalStatusYesUse ApprovalStatus.Rejected (-1) to decline the request.

Return value

Returns a Promise that resolves to void upon submission of the rejection.

State changes after the call

Resolving the Promise submits the rejection to the server. Listen for EventOnFriendApplicationRejected to update the application item in your list matching fromUserID:toUserID, as described in Retrieve received friend applications. Declining does not establish a friendship or delete the application record from history.