Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Send friend application

Send a friend request to a designated user with an optional verification message.

Copy

Do not send friend requests to your own userID or to users who are already friends. The reqMsg parameter provides greeting or verification notes, while ex contains custom application metadata:

Code example

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

const request: AddFriendReq = {
  userID: targetUserID,
  reqMsg: verificationMessage,
  ex: '',
};
await sdk.addFriend(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesTarget recipient user ID.
reqMsgstringNoOptional verification note or greeting message.
exstringNoCustom application metadata string.

Return value

Returns a Promise that resolves to void when the request has been submitted to the server.

State changes after the call

Promise resolution confirms that the application has been queued on the server; it does not mean that the target user has approved the request or that friendship has been established. To track outgoing applications, see Retrieve sent friend applications. For incoming request events, see Retrieve received friend applications.