Accept a friend application
Approve an incoming friend request from a specified user.
Invoke acceptFriendApplication() to accept an incoming friend request. When processing an incoming application, pass the applicant's user ID as toUserID rather than your own ID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
toUserID | string | Yes | The user ID of the applicant whose request is being accepted. |
handleMsg | string | Yes | Optional response message or approval note; pass an empty string if not required. |
Code example
import { acceptFriendApplication } from '@/uni_modules/unix-openim-sdk'
await acceptFriendApplication({
toUserID: applicantUserID,
handleMsg: '',
})Return value
The Promise resolves with void once OpenIMServer processes the approval.
State changes after the call
A resolved Promise indicates that the server accepted the request; it does not mean events have completed local state updates. Friend applications and friend rosters represent two separate data collections: upon receiving onFriendApplicationAccepted, update the application status in the request list; upon receiving onFriendAdded, merge the new friend into your contact roster by userID. To calibrate state, re-query both lists. For event listener patterns, see Get received friend applications and Get the friend list.
Was this page helpful?