Send a friend application
Submit an outgoing friend request to a specified user.
Invoke addFriend() to submit a friend application to a target user. Before sending, ensure the target is not the current user's own account or an existing friend.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
toUserID | string | Yes | The recipient user ID for the friend request. |
reqMsg | string | Yes | Verification greeting or justification message; pass an empty string if no message is required. |
ex | string | No | Optional business extension string agreed upon by application conventions. |
Code example
import { addFriend } from '@/uni_modules/unix-openim-sdk'
await addFriend({
toUserID,
reqMsg: verificationMessage,
})Return value
The Promise resolves with void once OpenIMServer receives the application.
State changes after the call
A resolved Promise confirms that the friend request was dispatched; it does not indicate that the recipient has accepted, nor should it trigger adding the user to the local friend list. Outgoing application logs are tracked via application events, while new friendships are established only after acceptance arrives via onFriendAdded. For application events, see Get received friend applications; for friend roster synchronization, see Get the friend list.
Was this page helpful?