searchFriends

Introduction

Search Friends

It will returns the user profile cached in local, while you can check the relationship with V2TIMFriendInfoResult.

This method can only search locally.

Parameter details

Parameter name Parameter type Required Description
V2TimFriendSearchParam yes The conditions for searching.

Returned template

V2TimValueCallback<V2TimFriendInfoResult[]>

{
    code : number
    desc : string
    data : V2TimFriendInfoResult[]
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data V2TimFriendInfoResult[] The list of search result.

Code example

import { TencentImSDKPlugin } from 'react-native-tim-js';


const searchParam = {
    isSearchNickName: true,
    isSearchRemark: true,
    isSearchUserID: true,
    keywordList: [],
};
const searchFriendsRes = await TencentImSDKPlugin.v2TIMManager
    .getFriendshipManager()
    .searchFriends(searchParam);
if (searchFriendsRes.code === 0) {

    searchFriendsRes.data?.forEach((element) => {
        element.relation;
        element.resultCode;
        element.resultInfo;

        element.friendInfo?.friendCustomInfo;
        element.friendInfo?.friendGroups;
        element.friendInfo?.friendRemark;
        element.friendInfo?.userID;
        element.friendInfo?.userProfile?.allowType;
        element.friendInfo?.userProfile?.birthday;
        element.friendInfo?.userProfile?.customInfo;
        element.friendInfo?.userProfile?.faceUrl;
        element.friendInfo?.userProfile?.gender;
        element.friendInfo?.userProfile?.level;
        element.friendInfo?.userProfile?.nickName;
        element.friendInfo?.userProfile?.role;
        element.friendInfo?.userProfile?.selfSignature;
        element.friendInfo?.userProfile?.userID;
    });
}

results matching ""

    No results matching ""