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 groups can be searched for, such as the list of joined groups and group profiles that have been pulled.
Note:
The local group search feature is supported only by Enhanced SDK v5.4.666 or later.
The local group 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 a Local Group

Call the searchGroups API (Java / Swift / Objective-C / C++) to search a local group.
You can set the search keyword keywordList and specify the search scope to set whether to search by the groupID and groupName fields of a group.
Sample code:
Java
Swift
Objective-C
C++
V2TIMGroupSearchParam searchParam = new V2TIMGroupSearchParam();
searchParam.setKeywordList(keywordList);
searchParam.setSearchGroupID(true);
searchParam.setSearchGroupName(true);

V2TIMManager.getGroupManager().searchGroups(searchParam, new V2TIMValueCallback<List<V2TIMGroupInfo>>() {
@Override
public void onSuccess(List<V2TIMGroupInfo> v2TIMGroupInfos) {
// Group found successfully
}

@Override
public void onError(int code, String desc) {
// Failed to find the group
}
});
let param = V2TIMGroupSearchParam()
param.keywordList = ["2", "key2"]
param.isSearchGroupID = true
param.isSearchGroupName = true

V2TIMManager.shared.searchGroups(searchParam: param) { groupList in
groupList.forEach { item in
print( item.description)
}
} fail: { code, desc in
print( "searchGroups fail, \(code), \(desc)")
}
V2TIMGroupSearchParam *searchParam = [[V2TIMGroupSearchParam alloc] init];
searchParam.keywordList = @[@"keyword1", @"keyword2"];
searchParam.isSearchGroupID = YES;
searchParam.isSearchGroupName = YES;
[[V2TIMManager sharedInstance] searchGroups:searchParam succ:^(NSArray<V2TIMGroupInfo *> *groupList) {
// Group found successfully
} fail:^(int code, NSString *desc) {
// Failed to find the group
}];
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_;
};

V2TIMGroupSearchParam searchParam;
searchParam.keywordList = keywordList;
searchParam.isSearchGroupID = true;
searchParam.isSearchGroupName = true;

auto callback = new ValueCallback<V2TIMGroupInfoVector>{};
callback->SetCallback(
[=](const V2TIMGroupInfoVector& groupInfoList) {
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
delete callback;
});

V2TIMManager::GetInstance()->GetGroupManager()->SearchGroups(searchParam, 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