getGroupMemberList
API (Android/iOS and macOS/Windows) to get the list of members in a specified group.
This list contains the profile of each group member, such as user ID (userID
), group name card (nameCard
), avatar (faceUrl
), nickname (nickName
), time of joining the group (joinTime
), online status (isOnline
), etc. getGroupMemberList
to pull the latest 1,000 group members. This feature needs to be enabled in the Console, configuration path: Applications > Your App > Chat > Configuration > Group Configuration > Group feature configuration > List of online audio-video group members.filter
) and pulling by page (nextSeq
).getGroupMemberList
API (Android/iOS and Mac/Windows), you can set filter
to V2TIMGroupMemberFilter
to pull the information of certain roles.Filter | Type |
V2TIM_GROUP_MEMBER_FILTER_ALL | Pull the information list of all group members |
V2TIM_GROUP_MEMBER_FILTER_OWNER | Pull the information list of the group owner |
V2TIM_GROUP_MEMBER_FILTER_ADMIN | Pull the information list of the group admin |
V2TIM_GROUP_MEMBER_FILTER_COMMON | Pull the information list of ordinary group members |
filter
to a custom group member mark other than V2TIMGroupMemberFilter
to filter group members as needed. For more information, see Marking Group Members.// Use the `filter` parameter to specify only the profile of the group owner is to be pulledint role = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_OWNER;V2TIMManager.getGroupManager().getGroupMemberList("testGroup", role, 0,new V2TIMValueCallback<V2TIMGroupMemberInfoResult>() {@Overridepublic void onError(int code, String desc) {// Messages failed to be pulled}@Overridepublic void onSuccess(V2TIMGroupMemberInfoResult v2TIMGroupMemberInfoResult) {// Conversations pulled successfully}});
[[V2TIMManager sharedInstance] getGroupMemberList:@"groupA" filter:V2TIM_GROUP_MEMBER_FILTER_OWNER nextSeq:0 succ:^(uint64_t nextSeq, NSArray<V2TIMGroupMemberFullInfo *> *memberList) {// Conversations pulled successfully} fail:^(int code, NSString *desc) {// Messages failed to be pulled}];
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_;};V2TIMString groupID = "testGroup";// Use the `filter` parameter to specify only the profile of the group owner is to be pulleduint32_t filter = V2TIMGroupMemberFilter::V2TIM_GROUP_MEMBER_FILTER_OWNER;uint64_t nextSeq = 0;auto callback = new ValueCallback<V2TIMGroupMemberInfoResult>{};callback->SetCallback([=](const V2TIMGroupMemberInfoResult& groupMemberInfoResult) {// Conversations pulled successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Messages failed to be pulleddelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->GetGroupMemberList(groupID, filter, nextSeq, callback);
getGroupMemberList
for the first time, set nextSeq
to 0
(indicating to pull the group member list from the beginning). Up to 50 group member objects can be pulled at a time.V2TIMGroupMemberInfoResult
callback of getGroupMemberList
will contain nextSeq
(field for the next pull):nextSeq
is 0
, all the group members have been pulled.nextSeq
is greater than 0
, there are more group members that can be pulled. This doesn't mean that the next page of the member list will be pulled immediately. In common software, a paged pull is often triggered by a swipe operation.getGroupMemberList
API and pass in the nextSeq
parameter (the value is from the V2TIMGroupMemberInfoResult
object returned by the last pull) for the next pull.nextSeq
is 0
.{...long nextSeq = 0;getGroupMemberList(nextSeq);...}public void getGroupMemberList(long nextSeq) {int filterRole = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_ALL;V2TIMManager.getGroupManager().getGroupMemberList("testGroup", filterRole, nextSeq,new V2TIMValueCallback<V2TIMGroupMemberInfoResult>() {@Overridepublic void onError(int code, String desc) {// Messages failed to be pulled}@Overridepublic void onSuccess(V2TIMGroupMemberInfoResult groupMemberInfoResult) {if (groupMemberInfoResult.getNextSeq() != 0) {// Make another pullgetGroupMemberList(groupMemberInfoResult.getNextSeq());...} else {// Pull ends}}});}
- (void)getGroupMemberList:(uint32_t)seq {[[V2TIMManager sharedInstance] getGroupMemberList:@"groupA" filter:V2TIM_GROUP_MEMBER_FILTER_OWNER nextSeq:seq succ:^(uint64_t nextSeq, NSArray<V2TIMGroupMemberFullInfo *> *memberList) {if (nextSeq != 0) {// Make another pull[self getGroupMemberList:nextSeq];//...} else {// Pull ends}} fail:^(int code, NSString *desc) {// Messages failed to be pulled}];}
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_;};V2TIMString groupID = "testGroup";uint32_t filter = V2TIMGroupMemberFilter::V2TIM_GROUP_MEMBER_FILTER_ALL;uint64_t nextSeq = 0;auto callback = new ValueCallback<V2TIMGroupMemberInfoResult>{};callback->SetCallback([=](const V2TIMGroupMemberInfoResult& groupMemberInfoResult) {if (groupMemberInfoResult.nextSequence != 0) {// Make another pull}delete callback;},[=](int error_code, const V2TIMString& error_message) {// Messages failed to be pulleddelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->GetGroupMemberList(groupID, filter, nextSeq, callback);
markGroupMemberList
API (Android/iOS and Mac/WIndows) to mark or unmark members of an audio-video group. Rules are as follows:filter
to a configured custom group member mark to filter group members as needed. muteGroupMember
(Android/iOS and macOS/Windows) and set muteTime
(in seconds) to mute a group member. If muteTime
is set to 120
, the member is muted for 120 seconds.
If a group member is muted, message sending will fail, and an error code will be reported. To unmute the member, set muteTime
to 0
.muteUntil
field (Android/iOS and macOS/Windows) of the group member information. Note that muteUntil
indicates the end time for muting a group member.onMemberInfoChanged
callback (Android/iOS and macOS/Windows).muteAllGroupMembers
API (Android/iOS and macOS/Windows) to mute the entire group by setting the isMute
field to true
/YES
. The entire group can be muted for an unlimited period of time.onGroupInfoChanged
callback (Android/iOS and Mac/Windows).// Mute the `userB` group member for one minuteV2TIMManager.getGroupManager().muteGroupMember("groupA", "userB", 60, new V2TIMCallback() {@Overridepublic void onSuccess() {// Muted the group member successfully}@Overridepublic void onError(int code, String desc) {// Failed to mute the group member}});// Mute all membersV2TIMManager.getGroupManager().muteAllGroupMembers("groupA", true, new V2TIMCallback() {@Overridepublic void onSuccess() {// Muted all successfully}@Overridepublic void onError(int code, String desc) {// Failed to mute all}});V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic void onMemberInfoChanged(String groupID, List<V2TIMGroupMemberChangeInfo> v2TIMGroupMemberChangeInfoList) {// Listen for the muting of a group memberfor (V2TIMGroupMemberChangeInfo memberChangeInfo : v2TIMGroupMemberChangeInfoList) {// ID of the muted userString userID = memberChangeInfo.getUserID();// Muting durationlong muteTime = memberChangeInfo.getMuteTime();}}@Overridepublic void onAllGroupMembersMuted(String groupID, boolean isMute) {// Listen for the muting of all}});
// Mute the group member `user1` for one minute[[V2TIMManager sharedInstance] muteGroupMember:@"groupA" member:@"user1" muteTime:60 succ:^{// Muted the group member successfully} fail:^(int code, NSString *desc) {// Failed to mute the group member}];// Mute all members[[V2TIMManager sharedInstance] muteAllGroupMembers:@"groupA" isMute:YES succ:^{// Muted all successfully} fail:^(int code, NSString *desc) {// Failed to mute all}];[[V2TIMManager sharedInstance] addGroupListener:self];- (void)onMemberInfoChanged:(NSString *)groupID changeInfoList:(NSArray <V2TIMGroupMemberChangeInfo *> *)changeInfoList {// Listen for the muting of a group memberfor (V2TIMGroupMemberChangeInfo *memberChangeInfo in changeInfoList) {// ID of the muted userNSString *userID = memberChangeInfo.userID;// Muting durationuint32_t muteTime = memberChangeInfo.muteTime;}}- (void)onAllGroupMembersMuted:(NSString *)groupID isMute:(BOOL)isMute {// Listen for the muting of all}
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}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_;};// Mute the `userB` group member for one minuteauto callback = new Callback;callback->SetCallback([=]() {// Muted the group member successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to mute the group memberdelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->MuteGroupMember("groupA", "userB", 60, callback);// Mute all membersV2TIMGroupInfo info;info.groupID = "groupA";info.allMuted = true;info.modifyFlag = V2TIMGroupInfoModifyFlag::V2TIM_GROUP_INFO_MODIFY_FLAG_SHUTUP_ALL;auto callback = new Callback;callback->SetCallback([=]() {// Muted all successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to mute alldelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->SetGroupInfo(info, callback);// Listen for the muting of a group member or allclass GroupListener final : public V2TIMGroupListener {public:GroupListener() = default;~GroupListener() override = default;void OnMemberInfoChanged(const V2TIMString& groupID,const V2TIMGroupMemberChangeInfoVector& groupMemberChangeInfoList) override {// Listen for the muting of a group memberfor (size_t i = 0; i < groupMemberChangeInfoList.Size(); ++i) {const V2TIMGroupMemberChangeInfo& groupMemberChangeInfo = groupMemberChangeInfoList[i];// ID of the muted userV2TIMString userID = groupMemberChangeInfo.userID;// Muting durationuint32_t muteTime = groupMemberChangeInfo.muteTime;}}void onAllGroupMembersMuted(const V2TIMString& groupID,bool isMute) override {// Listen for the muting of all}// Other members …};// Add a group event listener. Keep `groupListener` valid before the listener is removed to ensure event callbacks are received.GroupListener groupListener;V2TIMManager::GetInstance()->AddGroupListener(&groupListener);
kickGroupMember
① (Android/iOS & Mac/Windows) to kick a specified group member out of the group. After the Group member is kicked out, all members (including the kicked user) will receive the onMemberKicked
(Android/iOS & Mac/Windows) callback. List<String> userIDList = new ArrayList<>();userIDList.add("userB");V2TIMManager.getGroupManager().kickGroupMember("groupA", userIDList, "", newV2TIMValueCallback<List<V2TIMGroupMemberOperationResult>>() {@Overridepublic void onSuccess(List<V2TIMGroupMemberOperationResult> v2TIMGroupMemberOperationResults) {// Remove group members successfully}@Overridepublic void onError(int code, String desc) {// Failed to remove group members successfully}}});V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic void onMemberKicked(String groupID, V2TIMGroupMemberInfo opUser,List<V2TIMGroupMemberInfo> memberList) {// Group member kicked notification}});
[[V2TIMManager sharedInstance] kickGroupMember:@"groupA" memberList:@[@"user1"] reason:@"" succ:^(NSArray<V2TIMGroupMemberOperationResult *> *resultList) {// Remove group members successfully} fail:^(int code, NSString *desc) {// Failed to remove group members successfully}];[[V2TIMManager sharedInstance] addGroupListener:self];- (void)onMemberKicked:(NSString *)groupID opUser:(V2TIMGroupMemberInfo *)opUser memberList:(NSArray<V2TIMGroupMemberInfo *>*)memberList {// Group member kicked notification}
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_;};V2TIMString groupID = "groupA";V2TIMStringVector memberList;memberList.PushBack("userB");auto callback = new ValueCallback<V2TIMGroupMemberOperationResultVector>{};callback->SetCallback([=](const V2TIMGroupMemberOperationResultVector& groupMemberOperationResultList) {// Remove group members successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to remove group members successfullydelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->KickGroupMember(groupID, memberList, {}, callback);class GroupListener final : public V2TIMGroupListener {public:GroupListener() = default;~GroupListener() override = default;void OnMemberKicked(const V2TIMString& groupID, const V2TIMGroupMemberInfo& opUser, const V2TIMGroupMemberInfoVector& memberList) override {// Group member kicked notification}};// Note that `groupListener` should not be released before the IM SDK is uninitialized,// otherwise the message callback cannot be called.GroupListener groupListener;V2TIMManager::GetInstance()->AddGroupListener(&groupListener);
kickGroupMember
② (Android/iOS & Mac/Windows) , adding a duration
parameter to specify the duration which the user is prohibited from reapplying to join the group after being kicked out of the group.List<String> userIDList = new ArrayList<>();userIDList.add("userB");V2TIMManager.getGroupManager().kickGroupMember("groupA", userIDList, "", 100, newV2TIMValueCallback<List<V2TIMGroupMemberOperationResult>>() {@Overridepublic void onSuccess(List<V2TIMGroupMemberOperationResult> v2TIMGroupMemberOperationResults) {// Remove group members successfully}@Overridepublic void onError(int code, String desc) {// Failed to remove group members successfully}});V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic void onMemberKicked(String groupID, V2TIMGroupMemberInfo opUser,List<V2TIMGroupMemberInfo> memberList) {// Group member kicked notification}});
[[V2TIMManager sharedInstance] kickGroupMember:@"groupA" memberList:@[@"user1"] reason:@"" duration:100 succ:^(NSArray<V2TIMGroupMemberOperationResult *> *resultList) {// Remove group members successfully} fail:^(int code, NSString *desc) {// Failed to remove group members successfully}];[[V2TIMManager sharedInstance] addGroupListener:self];- (void)onMemberKicked:(NSString *)groupID opUser:(V2TIMGroupMemberInfo *)opUser memberList:(NSArray<V2TIMGroupMemberInfo *>*)memberList {// Group member kicked notification}
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_;};V2TIMString groupID = "groupA";V2TIMStringVector memberList;memberList.PushBack("userB");auto callback = new ValueCallback<V2TIMGroupMemberOperationResultVector>{};callback->SetCallback([=](const V2TIMGroupMemberOperationResultVector& groupMemberOperationResultList) {// Remove group members successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to remove group members successfullydelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->KickGroupMember(groupID, memberList, {}, 100, callback);class GroupListener final : public V2TIMGroupListener {public:GroupListener() = default;~GroupListener() override = default;void OnMemberKicked(const V2TIMString& groupID, const V2TIMGroupMemberInfo& opUser,const V2TIMGroupMemberInfoVector& memberList) override {// Group member kicked notification}};// Note that `groupListener` should not be released before the IM SDK is uninitialized,// otherwise the message callback cannot be called.GroupListener groupListener;V2TIMManager::GetInstance()->AddGroupListener(&groupListener);
muteGroupMember
(Android/iOS and Mac/Windows) to mute a specified member to implement similar controls. For detailed directions, see Muting.setGroupMemberRole
(Android/iOS and Mac/Windows) can grant admin authorization to group members in stranger social groups (Public), temporary meeting groups (Meeting), and audio-video groups (AVChatRoom).onGrantAdministrator
callback (Android/iOS and Mac/Windows).onRevokeAdministrator
callback (Android/iOS and Mac/Windows).V2TIMManager.getGroupManager().setGroupMemberRole("groupA", "userB", V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_ROLE_ADMIN, new V2TIMCallback() {@Overridepublic void onSuccess() {// Changed the group member role successfully}@Overridepublic void onError(int code, String desc) {// Failed to change the group member role}});V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic void onGrantAdministrator(String groupID, V2TIMGroupMemberInfo opUser,List<V2TIMGroupMemberInfo> memberList) {// A group member was set as the admin.}@Overridepublic void onRevokeAdministrator(String groupID, V2TIMGroupMemberInfo opUser,List<V2TIMGroupMemberInfo> memberList) {// A group member was unset as the admin.}});
[[V2TIMManager sharedInstance] setGroupMemberRole:@"groupA" member:@"user1" newRole:V2TIM_GROUP_MEMBER_ROLE_ADMIN succ:^{// Changed the group member role successfully} fail:^(int code, NSString *desc) {// Failed to change the group member role}];[[V2TIMManager sharedInstance] addGroupListener:self];- (void)onGrantAdministrator:(NSString *)groupID opUser:(V2TIMGroupMemberInfo *)opUser memberList:(NSArray <V2TIMGroupMemberInfo *> *)memberList {// A group member was set as the admin.}- (void)onRevokeAdministrator:(NSString *)groupID opUser:(V2TIMGroupMemberInfo *)opUser memberList:(NSArray <V2TIMGroupMemberInfo *> *)memberList {// A group member was unset as the admin.}
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}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_;};V2TIMString groupID = "groupA";V2TIMString userID = "userB";uint32_t role = V2TIMGroupMemberRole::V2TIM_GROUP_MEMBER_ROLE_ADMIN;auto callback = new Callback;callback->SetCallback([=]() {// Changed the group member role successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to change the group member roledelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->SetGroupMemberRole(groupID, userID, role, callback);// Listen for setting a user as the adminclass GroupListener final : public V2TIMGroupListener {public:GroupListener() = default;~GroupListener() override = default;void OnGrantAdministrator(const V2TIMString& groupID, const V2TIMGroupMemberInfo& opUser,const V2TIMGroupMemberInfoVector& memberList) override {// A group member was set as the admin.}void OnRevokeAdministrator(const V2TIMString& groupID, const V2TIMGroupMemberInfo& opUser,const V2TIMGroupMemberInfoVector& memberList) override {// A group member was unset as the admin.}// Other members …};// Add a group event listener. Keep `groupListener` valid before the listener is removed to ensure event callbacks are received.GroupListener groupListener;V2TIMManager::GetInstance()->AddGroupListener(&groupListener);
transferGroupOwner
(Android/iOS and Mac/Windows) to transfer the ownership of a group to another group member.onGroupInfoChanged
callback (Android/iOS and macOS/Windows). Here, the type
of V2TIMGroupChangeInfo
is V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER
, and the value is the UserID
of the new group owner.V2TIMManager.getGroupManager().transferGroupOwner("groupA", "userB", new V2TIMCallback() {@Overridepublic void onSuccess() {// Transferred the group ownership successfully}@Overridepublic void onError(int code, String desc) {// Failed to transfer the group ownership}});
[[V2TIMManager sharedInstance] transferGroupOwner:@"groupA" member:@"user1" succ:^{// Transferred the group ownership successfully} fail:^(int code, NSString *desc) {// Failed to transfer the group ownership}];
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}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_;};V2TIMString groupID = "groupA";V2TIMString userID = "userB";auto callback = new Callback;callback->SetCallback([=]() {// Transferred the group ownership successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to transfer the group ownershipdelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->TransferGroupOwner(groupID, userID, callback);
getGroupOnlineMemberCount
(Android/iOS and Mac/Windows) to get the number of online group members.V2TIMManager.getGroupManager().getGroupOnlineMemberCount("group_avchatroom", new V2TIMValueCallback<Integer>() {@Overridepublic void onSuccess(Integer integer) {// Obtained the number of online members in the audio-video group (AVChatRoom) successfully}@Overridepublic void onError(int code, String desc) {// Failed to obtain the number of online members in the audio-video group (AVChatRoom)}});
[[V2TIMManager sharedInstance] getGroupOnlineMemberCount:@"group_avchatroom" succ:^(NSInteger count) {// Obtained the number of online members in the audio-video group (AVChatRoom) successfully} fail:^(int code, NSString *desc) {// Failed to obtain the number of online members in the audio-video group (AVChatRoom)}];
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_;};V2TIMString groupID = "group_avchatroom";auto callback = new ValueCallback<uint32_t>{};callback->SetCallback([=](const uint32_t& count) {// Obtained the number of online members in the audio-video group (AVChatRoom) successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to obtain the number of online members in the audio-video group (AVChatRoom)delete callback;});V2TIMManager::GetInstance()->GetGroupManager()->GetGroupOnlineMemberCount(groupID, callback);
Was this page helpful?