SDKsHarmonyOSEnterprise
Send friend application
Send a friend request to a designated user with an optional verification message.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | string | Yes | Target recipient user ID. |
reqMsg | string | No | Optional verification note or greeting message. |
ex | string | No | Custom 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.
Was this page helpful?