이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

그룹 멤버 검색

Overview

Only locally stored group members can be searched for, such as the list of group members or group member profiles that have been pulled.
Note:
The local group member search feature is supported only by the Enhanced SDK on v5.4.666 or later. It cannot be used for audio-video groups (AVChatRoom) as the group members are not stored locally.
The local group member search feature is only available on the IM Premium edition. To use it, purchase the Premium Edition.

Searching for Local Group Members

Call the searchGroupMembers API (Android / iOS and Mac / Windows) to search for local group members. You can set the search keyword keywordList and specify the search scope to set whether to search by the memberUserID, memberNickName, memberRemark, and memberNameCard fields of group members.
Depending on whether groupIDList of V2TIMGroupMemberSearchParam (Android / iOS and macOS / Windows) in searchGroupMembers is empty (null/nil), there are two cases:
If groupIDList is left empty, members in all the groups will be searched for and returned by groupID.
If groupIDList is not left empty, members in the specified group will be searched for.
Sample code:
Android
iOS and macOS
Windows
V2TIMGroupMemberSearchParam searchParam = new V2TIMGroupMemberSearchParam();
searchParam.setGroupIDList(groupIDList);
searchParam.setKeywordList(keywordList);
searchParam.setSearchMemberUserID(true);
searchParam.setSearchMemberNickName(true);
searchParam.setSearchMemberRemark(true);
searchParam.setSearchMemberNameCard(true);

V2TIMManager.getGroupManager().searchGroupMembers(searchParam, new V2TIMValueCallback<HashMap<String, List<V2TIMGroupMemberFullInfo>>>() {
@Override
public void onSuccess(HashMap<String, List<V2TIMGroupMemberFullInfo>> stringListHashMap) {
StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, List<V2TIMGroupMemberFullInfo>> entry : stringListHashMap.entrySet()) {
// Group ID
String groupID = entry.getKey();
// Group member list
List<V2TIMGroupMemberFullInfo> memberFullInfoList = entry.getValue();
}
}
}

@Override
public void onError(int code, String desc) {
// Failed to find the group members
}
});
V2TIMGroupMemberSearchParam *searchParam = [[V2TIMGroupMemberSearchParam alloc] init];
searchParam.groupIDList = @[@"group1", @"group2"];
searchParam.keywordList = @[@"keyword1", @"keyword2"];
searchParam.isSearchMemberUserID = YES;
searchParam.isSearchMemberNickName = YES;
searchParam.isSearchMemberRemark = YES;
searchParam.isSearchMemberNameCard = YES;
[[V2TIMManager sharedInstance] searchGroupMembers:searchParam succ:^(NSDictionary<NSString *,NSArray<V2TIMGroupMemberFullInfo *> *> *memberList) {
for (NSString *key in memberList.allKeys) {
// Group ID
NSString *groupID = key;
// Group member list
NSArray *memberFullInfoList = memberList[key];
}
} fail:^(int code, NSString *desc) {
// Failed to find the group members
}];
template <class T>
class ValueCallback final : public V2TIMValueCallback<T> {
public:
using SuccessCallback = std::function<void(const T&)>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

ValueCallback() = default;
~ValueCallback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess(const T& value) override {
if (success_callback_) {
success_callback_(value);
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

V2TIMGroupMemberSearchParam param;
param.groupIDList = groupIDList;
param.keywordList = keywordList;
param.isSearchMemberUserID = true;
param.isSearchMemberNickName = true;
param.isSearchMemberRemark = true;
param.isSearchMemberNameCard = true;

auto callback = new ValueCallback<V2TIMGroupSearchGroupMembersMap>{};
callback->SetCallback(
[=](const V2TIMGroupSearchGroupMembersMap& groupSearchGroupMembersMap) {
V2TIMStringVector allKeys = groupSearchGroupMembersMap.AllKeys();
for (size_t i = 0; i < allKeys.Size(); i++) {
// Group ID
const V2TIMString& groupID = allKeys[i];
// Group member list
V2TIMGroupMemberFullInfoVector groupMemberFullInfoList = groupSearchGroupMembersMap.Get(groupID);
}
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to find the group members
delete callback;
});

V2TIMManager::GetInstance()->GetGroupManager()->SearchGroupMembers(param, callback);