tencent cloud

$0 14-Day TrialExperience EdgeOne for acceleration and security protection!

Feedback

Chat

Android&iOS&Windows&Mac

Last updated: 2025-01-14 15:38:54

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 Pro edition 、Pro Plus edition、Enterprise edition. To use it, purchase the Pro edition 、Pro Plus edition、Enterprise edition.

Searching for Local Group Members

Call the searchGroupMembers API (Java / Swift / Objective-C / C++) 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 (Java / Swift / Objective-C / C++) 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:
Java
Swift
Objective-C
C++
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
}
});
let param = V2TIMGroupMemberSearchParam()
param.groupIDList = ["group1","group2"]
param.keywordList = ["keyword1", "keyword2", "keyword3"];
param.isSearchMemberUserID = true
param.isSearchMemberNickName = true
param.isSearchMemberRemark = true
param.isSearchMemberNameCard = true

V2TIMManager.shared.searchGroupMembers(searchParam: param) { memberList in
memberList.forEach { (key: String, value: Array<V2TIMGroupMemberFullInfo>) in
print( "key:\\(key), value:\\(value)")
}
} fail: { code, desc in
print( "searchGroupMembers fail, \\(code), \\(desc)")
}
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);



Catalog

In The Article

Android&iOS&Windows&Mac

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon