SDKsAndroid
Check friendship status
Batch verify friendship relationships between specified users and the authenticated account using checkFriend().
Batch verify whether specified users have active friendship relationships with the authenticated account. This is typically used on user profile screens to toggle between "Add friend" and "Send message" actions.
Code example
OpenIMClient.getInstance().friendshipManager.checkFriend(
new OnBase<List<FriendshipInfo>>() {
@Override
public void onSuccess(List<FriendshipInfo> relations) {
// Update relationship UI using relations
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
Arrays.asList("user_a", "user_b")
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<List<FriendshipInfo>> | Yes | Callback delivering the asynchronous operation result. |
userIDs | List<String> | Yes | List of user IDs to check. |
Return value
The successful callback returns a List<FriendshipInfo>. Match records using userID as the primary key:
| Field | Description |
|---|---|
userID | Target user ID. |
result | Friendship status code: 1 indicates the user is an active friend and not blocked; 0 indicates no friendship exists. |
To retrieve detailed profiles including nicknames, avatars, and remarks, see Get friend profiles.
Was this page helpful?