checkFriend
Feature Introduction
Description
Verify friendship to determine if they are in your friend list.
Note
Since friendship is a mutual relationship, just verifying if the other party is in your friend list does not verify if you are in the other party's friend list.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<FriendshipInfo>> checkFriend({
required List<String> userIDList,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDList | List<String> | Yes | User ID List |
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
~ | List<FriendshipInfo> | Success Return |
FriendshipInfo
Field Name | Field Type | Description |
---|---|---|
userID | String | User UserID |
result | int | On checkFriend: result is 1 means friend (and not in the blacklist) |
Code Sample
final list = await OpenIM.iMManager.friendshipManager.checkFriend(userIDList: ['ID']);
Function Prototype
- (void)checkFriend:(NSArray <NSString *> *)usersID
onSuccess:(nullable OIMSimpleResultsCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
usersID | NSArray <NSString *> | Yes | User ID List |
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | NSArray< OIMSimpleResultInfo * > | Success Return |
onFailure | OIMFailureCallback | Failure Return |
OIMSimpleResultInfo
Field Name | Field Type | Description |
---|---|---|
userID | NSString | User ID |
result | NSInteger | On checkFriend: result is 1 means friend (and not in the blacklist) |
Code Sample
[OIMManager.manager checkFriend:@[]
onSuccess:^(NSArray<OIMSimpleResultInfo *> * _Nullable results) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void checkFriend(OnBase<List<FriendshipInfo>> callBack, List<String> uidList)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase<List<FriendshipInfo>> | Yes | Callback interface |
uidList | String | Yes | User ID Collection |
FriendInfo
Field Name | Field Type | Description |
---|---|---|
userID | String | User UserID |
result | int | 1 means friend (and not in the blacklist) |
Return Value
Code Sample
OpenIMClient.getInstance().friendshipManager.checkFriend(new OnBase<FriendshipInfo>(){...},uidList)
Function Prototype
type FriendshipInfo = {
result: number; // 1 is a friend, 0 is not
userID: string;
};
IMSDK.checkFriend(userIDList: string[], operationID?: string): Promise<WsResponse<FriendshipInfo[]>>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDList | string[] | Yes | User ID List |
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<FriendshipInfo[]>> | List of friendship information |
Promise.catch() | Promise<WsResponse> | Failure Callback |
Code Sample
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
const userIDList = ['userID1', 'userID2'];
IMSDK.checkFriend(userIDList)
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
type FriendshipInfo = {
result: number; // 1 is a friend, 0 is not
userID: string;
};
IMSDK.asyncApi('checkFriend', operationID: string, userIDList: string[]): Promise<FriendshipInfo[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for issue tracking, unique recommended based on current time and a random number |
userIDList | string[] | Yes | User ID List |
Return Value
The function is Promise-ified through the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to handle and judge the success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<FriendshipInfo[]> | List of friendship information |
Promise.catch() | Promise<CatchResponse> | Failure Callback |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
const userIDList = ['userID1', 'userID2'];
IMSDK.asyncApi('checkFriend', IMSDK.uuid(), userIDList)
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
type FriendshipInfo = {
result: number; // 1 is a friend, 0 is not
userID: string;
};
OpenIMSDKRN.checkFriend(userIDList: string[], operationID: string): Promise<FriendshipInfo[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDList | string[] | Yes | User ID list |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<FriendshipInfo[]> | List of friendship information |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
const userIDList = ['userID1', 'userID2'];
OpenIMSDKRN.checkFriend(userIDList, 'operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void CheckFriend(OnBase<List<UserIDResult>> cb, string[] userIdList)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<UserIDResult>> | Yes | Callback |
userIdList | string[] | Yes | User ID Array |
Code Example
IMSDK.CheckFriend((list,errCode,errMsg)=>{
}, {"userid1","userid2"});