tencent cloud

14天试用边缘安全加速平台 EO 限时免费

Feedback

Chat

Android&iOS&Windows&Mac

Last updated: 2025-01-23 15:34:18

Search Cloud Groups

Description

You can search for cloud groups by group ID, group name, and other information to quickly find the required group profile. This feature is particularly useful for scenarios where specific groups need to be found, such as finding interest groups to join in social settings.
Note:
The cloud group search feature is supported only by version 8.4 or later.
This feature is a value-added feature, see Billing Overview for more information.
If this service is not activated, calling the interface will return the error code 60020.

Search Cloud Groups Interface

Call the searchCloudGroups (Java / Swift / Objective-C / C++) interface to search for group information in the cloud.
The parameters ofV2TIMGroupSearchParam are as follows:
Parameter
Meaning
Description
keywordList
Keyword list
It can contain up to five keywords, the keyword will automatically match the group id and group name.
keywordListMatchType
Match type of the keyword list
You can set it to search with "OR" logic or "AND" logic. The values are V2TIM_KEYWORD_LIST_MATCH_TYPE_OR and V2TIM_KEYWORD_LIST_MATCH_TYPE_AND, respectively. By default, it uses "OR" logic.
searchCount
Search Count
Must be greater than 0, maximum supported is 100, default is 20.
searchCursor
Search Cursor
Starting position, fill in an empty character string for the first time, and fill in the searchCursor from the last V2TIMGroupSearchResult returned for subsequent pulls.

Group Search Result Class

The message search result class is V2TIMGroupSearchResultJava / Swift / Objective-C / C++). The parameters are as described below:
Parameter
Meaning
Description
isFinished
Is the search finished
Whether all groups that meet the search criteria have been returned.
totalCount
Total search results
The total count of groups that meet the search criteria.
nextCursor
Continue pulling the cursor
The search cursor for the next cloud search.
groupList
Group List
The group list returned by the current cloud search.
Below is the sample code:
Java
Swift
Objective-C
C++
V2TIMGroupSearchParam searchParam = new V2TIMGroupSearchParam();
searchParam.setKeywordList(keywordList);
searchParam.setKeywordListMatchType(param.V2TIM_KEYWORD_LIST_MATCH_TYPE_OR);
searchParam.setSearchCount(20);
searchParam.setSearchCursor("");

V2TIMManager.getGroupManager().searchCloudGroups(searchParam, new V2TIMValueCallback<V2TIMGroupSearchResult>() {
@Override
public void onSuccess(V2TIMGroupSearchResult groupSearchResult) {
// search cloud groups succ
}

@Override
public void onError(int code, String desc) {
// search cloud groups succ failed
}
});
let param = V2TIMGroupSearchParam()
param.keywordList = ["keyword1", "keyword2"];
param.keywordListMatchType = .V2TIM_KEYWORD_LIST_MATCH_TYPE_OR;
param.searchCount = 20;
param.searchCursor = "";
V2TIMManager.shared.searchCloudGroups(searchParam: param) { searchResult in
// search cloud groups succ
} fail: { code, desc in
// search cloud groups succ failed
}
V2TIMGroupSearchParam *param = [[V2TIMGroupSearchParam alloc] init];
param.keywordList = @[@"keyword1", @"keyword2"];
param.keywordListMatchType = V2TIM_KEYWORD_LIST_MATCH_TYPE_OR;
param.searchCount = 20;
param.searchCursor = @"";
[[V2TIMManager sharedInstance] searchCloudGroups:param succ:^(V2TIMGroupSearchResult *searchResult) {
// search cloud groups succ
} fail:^(int code, NSString *desc) {
// search cloud groups succ failed
}];
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.keywordListMatchType = V2TIM_KEYWORD_LIST_MATCH_TYPE_OR;
searchParam.searchCount = 20;
searchParam.searchCursor = "";

auto callback = new ValueCallback<V2TIMGroupSearchResult>{};
callback->SetCallback(
[=](const V2TIMGroupSearchResult& groupSearchResult) {
// search cloud groups succ
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// search cloud groups succ failed
delete callback;
});

V2TIMManager::GetInstance()->GetGroupManager()->SearchCloudGroups(searchParam, callback);

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
中国香港
+852 800 906 020 (免费)
美国
+1 844 606 0804 (免费)
英国
+44 808 196 4551 (免费)
加拿大
+1 888 605 7930 (免费)
澳大利亚
+61 1300 986 386 (免费)
EdgeOne 热线
+852 300 80699
更多本地服务热线陆续新增中