Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Send a friend application

Submit an outgoing friend request to a specified user.

Copy

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

ParameterTypeRequiredDescription
toUserIDstringYesThe recipient user ID for the friend request.
reqMsgstringYesVerification greeting or justification message; pass an empty string if no message is required.
exstringNoOptional 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.