Browse SDKs · Flutter
Platform
SDKsFlutter

Add a friend

Send a friend application with a verification remark using the OpenIM Flutter SDK.

Copy

Send a friend request to a target user with an optional verification remark:

Parameters

ParameterTypeRequiredDescription
userIDStringYesTarget user ID to add as a friend.
reasonStringNoOptional verification remark message.

Code example

await OpenIM.iMManager.friendshipManager.addFriend(
  userID: 'user_b',
  reason: 'Hi, I am Alex',
);

Return value

A successful Future indicates that the friend application was accepted and queued by the server.

State changes after the call

A successful call signifies only that the application has been transmitted; it does not establish a friendship immediately. Once the recipient approves the request, both users receive friend addition events via their listeners. To monitor the status of sent applications, see Get friend application list as applicant.