Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Accept friend application

Approve a pending friend request from a designated user.

Copy

Accept an incoming friend request by supplying the applicant's user ID:

Code example

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

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

Parameters

ParameterTypeRequiredDescription
userIDstringYesApplicant's user identifier.
handleMsgstringNoOptional acceptance note or greeting message.
statusApprovalStatusYesUse ApprovalStatus.Approved (1) to accept the request.

Return value

Returns a Promise that resolves to void when the approval is processed on the server.

State changes after the call

Resolving the Promise confirms approval on the server. Update the application status in your request view via EventOnFriendApplicationAccepted correlated by fromUserID:toUserID, as described in Retrieve received friend applications. The newly established friendship triggers EventOnFriendAdded; see Paginate friend list for directory synchronization.