ZEGOCLOUD's In-app Chat (the ZIM SDK) provides the capability of group management, allowing you to create a group, ungroup, join and leave a group, and maintain the group relation chain.
With the group management feature, you can create different types of group chats as needed, such as colleague groups, social groups, fan groups, and more.
Create a group
After user A logs in to the ZIM SDK on a client, the user can call the createGroup method to create a group with advanced settings. In this case, user A logged on this client is the group owner, and users on other clients can join this group using the groupID.
You can check whether the group is created through the ZIMGroupCreatedCallback callback. For more information about error codes, see Error codes.
Warning
You can specify custom rules for groupID generation. A group ID can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~', and cannot start with a pound sign (#). If this parameter is empty, the ZIM server automatically generates a value. We recommend that you set a meaningful group ID generation rule. You can associate the group ID with your business account system.
If a user calls the createGroup method to create a group, the user automatically joins the group without calling the joinGroup method.
The user creating a group is the group owner. For more information about group ownership transfer, see Transfer the group ownership.
To specify the maximum number of group members and the group joining mode (including the approval mode, invitation mode, and whether the invitation needs to be approved by the invitee), integrate ZIM SDK 2.15.0 or later.
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
ZIMGroupInfo groupInfo = new ZIMGroupInfo();
groupInfo.groupID = "group_id";
groupInfo.groupName = "groupName";
groupInfo.groupAvatarUrl = "groupAvatarUrl";
ZIMGroupAdvancedConfig config = new ZIMGroupAdvancedConfig();
HashMap<String, String> attributes = new HashMap<>();
attributes.put("key_0", "value_0");
attributes.put("key_1", "value_1");
attributes.put("key_2", "value_2");
config.groupAttributes = attributes;
// // The mode where a user sends a group joining application.
config.joinMode = ZIMGroupJoinMode.ANY;
// The mode where a group member invites a user to a group.
config.inviteMode = ZIMGroupInviteMode.ANY;
// The mode where a user is invited to a group.
config.beInviteMode = ZIMGroupBeInviteMode.NONE;
// The maximum number of members in the group.
config.maxMemberCount = 300;
ArrayList<String> userList = new ArrayList<>();
userList.add("user_1");
userList.add("user_2");
zim.createGroup(groupInfo, userList, config, new ZIMGroupCreatedCallback() {
@Override
public void onGroupCreated(ZIMGroupFullInfo groupInfo, ArrayList<ZIMGroupMemberInfo> userIDs, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of creating a group through errorInfo.code
}
});
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
ZIMGroupInfo groupInfo = new ZIMGroupInfo();
groupInfo.groupID = "group_id";
groupInfo.groupName = "groupName";
groupInfo.groupAvatarUrl = "groupAvatarUrl";
ZIMGroupAdvancedConfig config = new ZIMGroupAdvancedConfig();
HashMap<String, String> attributes = new HashMap<>();
attributes.put("key_0", "value_0");
attributes.put("key_1", "value_1");
attributes.put("key_2", "value_2");
config.groupAttributes = attributes;
// // The mode where a user sends a group joining application.
config.joinMode = ZIMGroupJoinMode.ANY;
// The mode where a group member invites a user to a group.
config.inviteMode = ZIMGroupInviteMode.ANY;
// The mode where a user is invited to a group.
config.beInviteMode = ZIMGroupBeInviteMode.NONE;
// The maximum number of members in the group.
config.maxMemberCount = 300;
ArrayList<String> userList = new ArrayList<>();
userList.add("user_1");
userList.add("user_2");
zim.createGroup(groupInfo, userList, config, new ZIMGroupCreatedCallback() {
@Override
public void onGroupCreated(ZIMGroupFullInfo groupInfo, ArrayList<ZIMGroupMemberInfo> userIDs, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of creating a group through errorInfo.code
}
});
// Create a group
// groupID is a string with a maximum of 32 bytes. Only numbers, English characters, and the following special characters are supported: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with '#'.
// groupName is a string with a maximum of 50 bytes, no special character restrictions
ZIMGroupInfo groupInfo = ZIMGroupInfo();
groupInfo.groupID = 'groupID';
groupInfo.groupName = 'groupName';
List<String> inviteUserIDs = ['userID1', 'userID2'];
ZIMGroupAdvancedConfig advancedConfig = ZIMGroupAdvancedConfig();
// Active joining mode
advancedConfig.joinMode = ZIMGroupJoinMode.any;
// Invitation verification mode
advancedConfig.inviteMode = ZIMGroupInviteMode.any;
// Be invited verification mode
advancedConfig.beInviteMode = ZIMGroupBeInviteMode.none;
// Member count limit
advancedConfig.maxMemberCount = 300;
try{
await ZIM.getInstance()!.createGroup(groupInfo, inviteUserIDs,advancedConfig);
// Write your business logic after creating the group here
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Create a group
// groupID is a string with a maximum of 32 bytes. Only numbers, English characters, and the following special characters are supported: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with '#'.
// groupName is a string with a maximum of 50 bytes, no special character restrictions
ZIMGroupInfo groupInfo = ZIMGroupInfo();
groupInfo.groupID = 'groupID';
groupInfo.groupName = 'groupName';
List<String> inviteUserIDs = ['userID1', 'userID2'];
ZIMGroupAdvancedConfig advancedConfig = ZIMGroupAdvancedConfig();
// Active joining mode
advancedConfig.joinMode = ZIMGroupJoinMode.any;
// Invitation verification mode
advancedConfig.inviteMode = ZIMGroupInviteMode.any;
// Be invited verification mode
advancedConfig.beInviteMode = ZIMGroupBeInviteMode.none;
// Member count limit
advancedConfig.maxMemberCount = 300;
try{
await ZIM.getInstance()!.createGroup(groupInfo, inviteUserIDs,advancedConfig);
// Write your business logic after creating the group here
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
zim::ZIMGroupInfo group_info;
group_info.groupID = "group_id";
group_info.groupName = "groupName";
group_info.groupAvatarUrl = "groupAvatarUrl";
zim::ZIMGroupAdvancedConfig config;
config.groupAttributes.emplace("key_0", "value_0");
config.groupAttributes.emplace("key_1", "value_1");
config.groupAttributes.emplace("key_2", "value_2");
/**
* Group entry verification mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_JOIN_MODE_ANY: 0, default value, anyone can join the group directly.
* ZIM_GROUP_JOIN_MODE_AUTH: 1, group owner or administrator approval is required to join the group.
* ZIM_GROUP_JOIN_MODE_FORBID: 2, prohibit other users from joining the group.
*/
config.joinMode = zim::ZIMGroupJoinMode::ZIM_GROUP_JOIN_MODE_AUTH;
/**
* Invite mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_INVITE_MODE_ANY: 0, default value, any group member can invite external members to join the group.
* ZIM_GROUP_INVITE_MODE_ADMIN: 1, only group owners or administrators can invite external members to join the group
*/
config.inviteMode = zim::ZIMGroupInviteMode::ZIM_GROUP_INVITE_MODE_ADMIN;
/**
* Invite target user verification mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_BEINVITE_MODE_NONE: 0, default value, no need for the invitee's consent, the user automatically becomes a group member.
* ZIM_GROUP_BEINVITE_MODE_AUTH: 1, the invitee becomes a group member after consent.
*/
config.beInviteMode = zim::ZIMGroupBeInviteMode::ZIM_GROUP_BE_INVITE_MODE_AUTH;
/**
* The upper limit of the number of group members, only supports ZIM SDK version 2.15.0 and above
* Value range: [0, the default maximum number of group members for the package].
*/
config.maxMemberCount = 100;
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->createGroup(group_info, user_list, config,
[=](const zim::ZIMGroupFullInfo &groupInfo,
const std::vector<zim::ZIMGroupMemberInfo> &userList,
const std::vector<zim::ZIMErrorUser> &errorUserList,
zim::ZIMError errorInfo {
int error_code = errorInfo.code;
});
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
zim::ZIMGroupInfo group_info;
group_info.groupID = "group_id";
group_info.groupName = "groupName";
group_info.groupAvatarUrl = "groupAvatarUrl";
zim::ZIMGroupAdvancedConfig config;
config.groupAttributes.emplace("key_0", "value_0");
config.groupAttributes.emplace("key_1", "value_1");
config.groupAttributes.emplace("key_2", "value_2");
/**
* Group entry verification mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_JOIN_MODE_ANY: 0, default value, anyone can join the group directly.
* ZIM_GROUP_JOIN_MODE_AUTH: 1, group owner or administrator approval is required to join the group.
* ZIM_GROUP_JOIN_MODE_FORBID: 2, prohibit other users from joining the group.
*/
config.joinMode = zim::ZIMGroupJoinMode::ZIM_GROUP_JOIN_MODE_AUTH;
/**
* Invite mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_INVITE_MODE_ANY: 0, default value, any group member can invite external members to join the group.
* ZIM_GROUP_INVITE_MODE_ADMIN: 1, only group owners or administrators can invite external members to join the group
*/
config.inviteMode = zim::ZIMGroupInviteMode::ZIM_GROUP_INVITE_MODE_ADMIN;
/**
* Invite target user verification mode, only supports ZIM SDK version 2.15.0 and above
* ZIM_GROUP_BEINVITE_MODE_NONE: 0, default value, no need for the invitee's consent, the user automatically becomes a group member.
* ZIM_GROUP_BEINVITE_MODE_AUTH: 1, the invitee becomes a group member after consent.
*/
config.beInviteMode = zim::ZIMGroupBeInviteMode::ZIM_GROUP_BE_INVITE_MODE_AUTH;
/**
* The upper limit of the number of group members, only supports ZIM SDK version 2.15.0 and above
* Value range: [0, the default maximum number of group members for the package].
*/
config.maxMemberCount = 100;
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->createGroup(group_info, user_list, config,
[=](const zim::ZIMGroupFullInfo &groupInfo,
const std::vector<zim::ZIMGroupMemberInfo> &userList,
const std::vector<zim::ZIMErrorUser> &errorUserList,
zim::ZIMError errorInfo {
int error_code = errorInfo.code;
});
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
const groupInfo: ZIMGroupInfo = { groupID: '', groupName: '', groupAvatarUrl: '' };
const userIDs = [];
// Set the group joining mode and the upper limit of the group number
const config: ZIMGroupAdvancedConfig = {
/**
* Group joining verification mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) Anyone can join the group directly.
* 1: Group owner or administrator approval is required to join the group.
* 2: Other users are prohibited from joining the group.
*/
joinMode: 1,
/**
* Invite mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) Any group member can invite external members to join the group.
* 1: Only group owners or administrators can invite external members to join the group.
*/
inviteMode: 1,
/**
* Invite target user verification mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) The user automatically becomes a group member without the consent of the invitee.
* 1: The invitee becomes a group member after consent.
*/
beInviteMode: 1,
/**
* Group member limit, only supports ZIM SDK version 2.15.0 and above
* Value range: [0, the default maximum number of group members for the package].
*/
maxMemberCount: 100 // Limit the total number of group members to 100
};
zim.createGroup(groupInfo, userIDs, config)
.then(function ({ groupInfo, userList, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
const groupInfo: ZIMGroupInfo = { groupID: '', groupName: '', groupAvatarUrl: '' };
const userIDs = [];
// Set the group joining mode and the upper limit of the group number
const config: ZIMGroupAdvancedConfig = {
/**
* Group joining verification mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) Anyone can join the group directly.
* 1: Group owner or administrator approval is required to join the group.
* 2: Other users are prohibited from joining the group.
*/
joinMode: 1,
/**
* Invite mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) Any group member can invite external members to join the group.
* 1: Only group owners or administrators can invite external members to join the group.
*/
inviteMode: 1,
/**
* Invite target user verification mode, only supports ZIM SDK version 2.15.0 and above
* 0: (Default) The user automatically becomes a group member without the consent of the invitee.
* 1: The invitee becomes a group member after consent.
*/
beInviteMode: 1,
/**
* Group member limit, only supports ZIM SDK version 2.15.0 and above
* Value range: [0, the default maximum number of group members for the package].
*/
maxMemberCount: 100 // Limit the total number of group members to 100
};
zim.createGroup(groupInfo, userIDs, config)
.then(function ({ groupInfo, userList, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
ZIMGroupInfo *groupInfo = [[ZIMGroupInfo alloc] init];
groupInfo.groupID = @"groupID";
groupInfo.groupName = @"groupName";
groupInfo.groupAvatarUrl = @"groupAvatarUrl";
ZIMGroupAdvancedConfig *advancedConfig = [[ZIMGroupAdvancedConfig alloc] init];
// The mode where a user sends a group joining application.
advancedConfig.joinMode = ZIMGroupJoinModeAny;
// The mode where a group member invites a user to a group.
advancedConfig.inviteMode = ZIMGroupInviteModeAny;
// The mode where a user is invited to a group.
advancedConfig.beInviteMode = ZIMGroupBeInviteModeNone;
// The maximum number of members in the group.
advancedConfig.maxMemberCount = 300;
[[ZIM getInstance] createGroup:groupInfo userIDs:@[@"userID1",@"userID2"] config:advancedConfig callback:^(ZIMGroupFullInfo * _Nonnull groupInfo, NSArray<ZIMGroupMemberInfo *> * _Nonnull userList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the group is created.
}];
// Create a group.
// The groupID parameter can contain up to 32 bytes in length, including digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '|', '~'. It cannot start with a pound sign (#).
// The groupName parameter can contain up to 50 bytes in length, with no limit on characters.
ZIMGroupInfo *groupInfo = [[ZIMGroupInfo alloc] init];
groupInfo.groupID = @"groupID";
groupInfo.groupName = @"groupName";
groupInfo.groupAvatarUrl = @"groupAvatarUrl";
ZIMGroupAdvancedConfig *advancedConfig = [[ZIMGroupAdvancedConfig alloc] init];
// The mode where a user sends a group joining application.
advancedConfig.joinMode = ZIMGroupJoinModeAny;
// The mode where a group member invites a user to a group.
advancedConfig.inviteMode = ZIMGroupInviteModeAny;
// The mode where a user is invited to a group.
advancedConfig.beInviteMode = ZIMGroupBeInviteModeNone;
// The maximum number of members in the group.
advancedConfig.maxMemberCount = 300;
[[ZIM getInstance] createGroup:groupInfo userIDs:@[@"userID1",@"userID2"] config:advancedConfig callback:^(ZIMGroupFullInfo * _Nonnull groupInfo, NSArray<ZIMGroupMemberInfo *> * _Nonnull userList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the group is created.
}];
Join a group
Note
If you want users to automatically obtain group history messages after joining a group, please contact the ZEGOCLOUD technical support team for configuration.
After logging in to the ZIM SDK, users can apply to join or be invited to join a group created by user A.
// Listen for onGroupMemberStateChanged and onGroupStateChanged
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupMemberStateChanged(ZIM zim, ZIMGroupMemberState state, ZIMGroupMemberEvent event, ArrayList<ZIMGroupMemberInfo> userList, ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Callback notification of group member status change.
}
public void onGroupStateChanged(ZIM zim, ZIMGroupState state, ZIMGroupEvent event, ZIMGroupOperatedInfo operatedInfo, ZIMGroupFullInfo groupInfo) {
// Callback notification of group status change.
}
});
// Listen for onGroupMemberStateChanged and onGroupStateChanged
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupMemberStateChanged(ZIM zim, ZIMGroupMemberState state, ZIMGroupMemberEvent event, ArrayList<ZIMGroupMemberInfo> userList, ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Callback notification of group member status change.
}
public void onGroupStateChanged(ZIM zim, ZIMGroupState state, ZIMGroupEvent event, ZIMGroupOperatedInfo operatedInfo, ZIMGroupFullInfo groupInfo) {
// Callback notification of group status change.
}
});
// Callback for group member state change
ZIMEventHandler.onGroupMemberStateChanged = (
ZIM zim,
ZIMGroupMemberState state,
ZIMGroupMemberEvent event,
List<ZIMGroupMemberInfo> userList,
ZIMGroupOperatedInfo operatedInfo,
String groupID
){};
// Callback for group state change
ZIMEventHandler.onGroupStateChanged = (
ZIM zim,
ZIMGroupState state,
ZIMGroupEvent event,
ZIMGroupOperatedInfo operatedInfo,
ZIMGroupFullInfo groupInfo
){};
// Callback for group member state change
ZIMEventHandler.onGroupMemberStateChanged = (
ZIM zim,
ZIMGroupMemberState state,
ZIMGroupMemberEvent event,
List<ZIMGroupMemberInfo> userList,
ZIMGroupOperatedInfo operatedInfo,
String groupID
){};
// Callback for group state change
ZIMEventHandler.onGroupStateChanged = (
ZIM zim,
ZIMGroupState state,
ZIMGroupEvent event,
ZIMGroupOperatedInfo operatedInfo,
ZIMGroupFullInfo groupInfo
){};
The user calls the corresponding method to apply to join a group based on the joinMode of the group.
If the joinMode is set to 0 (ANY), the user calls the joinGroup method and passes in the groupID to join the group without approval. If the groupID does not exist, the operation fails.
Developers can determine whether the user successfully joins the group through ZIMGroupJoinedResult.
// Join the group on another client.
zim.joinGroup("groupID", new ZIMGroupJoinedCallback() {
@Override
public void onGroupJoined(ZIMGroupFullInfo groupInfo, ZIMError errorInfo) {
//Get the result of joining the group through errorInfo.code.
}
});
// Join the group on another client.
zim.joinGroup("groupID", new ZIMGroupJoinedCallback() {
@Override
public void onGroupJoined(ZIMGroupFullInfo groupInfo, ZIMError errorInfo) {
//Get the result of joining the group through errorInfo.code.
}
});
// Other clients join the group directly
ZIM.getInstance()
!.joinGroup('groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// Other clients join the group directly
ZIM.getInstance()
!.joinGroup('groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// Join the group on another client.
zim_->joinGroup(group_id,
[=](const zim::ZIMGroupFullInfo &groupInfo, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
// Join the group on another client.
zim_->joinGroup(group_id,
[=](const zim::ZIMGroupFullInfo &groupInfo, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
const groupID = '';
// Join the group on another client.
zim.joinGroup(groupID)
.then(function ({ groupInfo }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
const groupID = '';
// Join the group on another client.
zim.joinGroup(groupID)
.then(function ({ groupInfo }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Join the group on another client.
[zim joinGroup:GroupID callback:^(ZIMGroupFullInfo * _Nonnull groupInfo, ZIMError * _Nonnull errorInfo) {
// The business logic after the joinGroup method is called.
}];
// Join the group on another client.
[zim joinGroup:GroupID callback:^(ZIMGroupFullInfo * _Nonnull groupInfo, ZIMError * _Nonnull errorInfo) {
// The business logic after the joinGroup method is called.
}];
ZIMGroupJoinApplicationSendConfig config = new ZIMGroupJoinApplicationSendConfig();
config.wording = @"Let me join the group.";
zim.sendGroupJoinApplication("groupID", config, new ZIMGroupJoinApplicationSentCallback() {
@Override
public void onGroupJoinApplicationSent(String groupID, ZIMError errorInfo){
// The callback for sending the group joining application.
}];
ZIMGroupJoinApplicationSendConfig config = new ZIMGroupJoinApplicationSendConfig();
config.wording = @"Let me join the group.";
zim.sendGroupJoinApplication("groupID", config, new ZIMGroupJoinApplicationSentCallback() {
@Override
public void onGroupJoinApplicationSent(String groupID, ZIMError errorInfo){
// The callback for sending the group joining application.
}];
ZIMGroupJoinApplicationSendConfig sendConfig = ZIMGroupJoinApplicationSendConfig();
sendConfig.wording = 'Please let me join the group';
try{
var result = await ZIM.getInstance()!.sendGroupJoinApplication('groupID', sendConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
ZIMGroupJoinApplicationSendConfig sendConfig = ZIMGroupJoinApplicationSendConfig();
sendConfig.wording = 'Please let me join the group';
try{
var result = await ZIM.getInstance()!.sendGroupJoinApplication('groupID', sendConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
// Listen for groupApplicationListChanged event.
zim.on('groupApplicationListChanged', (zim, { action, applicationList }) => {
// Added group application, you can now update the group application list UI.
console.log(action, applicationList);
});
// Listen for groupApplicationListChanged event.
zim.on('groupApplicationListChanged', (zim, { action, applicationList }) => {
// Added group application, you can now update the group application list UI.
console.log(action, applicationList);
});
// Approve the application.
ZIMGroupJoinApplicationAcceptConfig config = new ZIMGroupJoinApplicationAcceptConfig();
zim.acceptGroupJoinApplication("userID", "groupID", config, new ZIMGroupJoinApplicationAcceptedCallback(){
public void onGroupJoinApplicationAccepted(String groupID, String userID, ZIMError errorInfo){
// The callback for application approval.
}];
// Approve the application.
ZIMGroupJoinApplicationAcceptConfig config = new ZIMGroupJoinApplicationAcceptConfig();
zim.acceptGroupJoinApplication("userID", "groupID", config, new ZIMGroupJoinApplicationAcceptedCallback(){
public void onGroupJoinApplicationAccepted(String groupID, String userID, ZIMError errorInfo){
// The callback for application approval.
}];
// Approve the application
try{
ZIMGroupJoinApplicationAcceptConfig acceptConfig = ZIMGroupJoinApplicationAcceptConfig();
var result = await ZIM.getInstance()!.acceptGroupJoinApplication('userID', 'groupID', acceptConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
// Approve the application
try{
ZIMGroupJoinApplicationAcceptConfig acceptConfig = ZIMGroupJoinApplicationAcceptConfig();
var result = await ZIM.getInstance()!.acceptGroupJoinApplication('userID', 'groupID', acceptConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
// Reject the application.
ZIMGroupJoinApplicationRejectConfig config = new ZIMGroupJoinApplicationRejectConfig();
zim.rejectGroupJoinApplication("userID", "groupID", config, new ZIMGroupJoinApplicationRejectedCallback(){
public void onGroupJoinApplicationRejected(String groupID, String userID, ZIMError errorInfo) { // The callback for application rejection.
}];
// Reject the application.
ZIMGroupJoinApplicationRejectConfig config = new ZIMGroupJoinApplicationRejectConfig();
zim.rejectGroupJoinApplication("userID", "groupID", config, new ZIMGroupJoinApplicationRejectedCallback(){
public void onGroupJoinApplicationRejected(String groupID, String userID, ZIMError errorInfo) { // The callback for application rejection.
}];
// Reject the application
try{
ZIMGroupJoinApplicationRejectConfig rejectConfig = ZIMGroupJoinApplicationRejectConfig();
var result = await ZIM.getInstance()!.rejectGroupJoinApplication('userID', 'groupID', rejectConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
// Reject the application
try{
ZIMGroupJoinApplicationRejectConfig rejectConfig = ZIMGroupJoinApplicationRejectConfig();
var result = await ZIM.getInstance()!.rejectGroupJoinApplication('userID', 'groupID', rejectConfig);
} on PlatformException catch (onError){
onError.code;
onError.message;
}
// Listen for groupApplicationUpdated event.
zim.on('groupApplicationUpdated', (zim, { applicationList }) => {
// The group application has changed. You can update the group application list UI at this time
console.log(applicationList);
});
// Listen for groupApplicationUpdated event.
zim.on('groupApplicationUpdated', (zim, { applicationList }) => {
// The group application has changed. You can update the group application list UI at this time
console.log(applicationList);
});
// A group member invites a user to the group.
ArrayList<String> userList = new ArrayList<>();
userList.add("user_1");
userList.add("user_2");
zim.inviteUsersIntoGroup(userList, "group_id", new ZIMGroupUsersInvitedCallback() {
@Override
public void onGroupUsersInvited(ArrayList<ZIMGroupMemberInfo> userList, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of adding to the group through errorInfo.code.
}
});
// A group member invites a user to the group.
ArrayList<String> userList = new ArrayList<>();
userList.add("user_1");
userList.add("user_2");
zim.inviteUsersIntoGroup(userList, "group_id", new ZIMGroupUsersInvitedCallback() {
@Override
public void onGroupUsersInvited(ArrayList<ZIMGroupMemberInfo> userList, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of adding to the group through errorInfo.code.
}
});
Developers can use ZIMGroupUsersInvitedResult to determine whether the user has been successfully added to the group.
// Add members to the group from within the group
List<String> userIDs = ['userID1', 'userID2'];
ZIM.getInstance()
!.inviteUsersIntoGroup(userIDs, 'groupID')
.then((value) => {
// Call this if successful
})
.catchError((onError) {
// Call this if failed
});
// Add members to the group from within the group
List<String> userIDs = ['userID1', 'userID2'];
ZIM.getInstance()
!.inviteUsersIntoGroup(userIDs, 'groupID')
.then((value) => {
// Call this if successful
})
.catchError((onError) {
// Call this if failed
});
// A group member invites a user to the group.
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->inviteUsersIntoGroup(user_list, group_id, callback);
// A group member invites a user to the group.
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->inviteUsersIntoGroup(user_list, group_id, callback);
const groupID = '';
// Added to the group by group members.
const userIDs = [];
zim.inviteUsersIntoGroup(userIDs, groupID)
.then(function ({ groupID, userList, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
const groupID = '';
// Added to the group by group members.
const userIDs = [];
zim.inviteUsersIntoGroup(userIDs, groupID)
.then(function ({ groupID, userList, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// A group member invites a user to the group.
[zim inviteUsersIntoGroup:userIDs groupID:groupID callback:^(NSArray<ZIMGroupMemberInfo *> * _Nonnull userList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the inviteUsersIntoGroup method is called.
}];
// A group member invites a user to the group.
[zim inviteUsersIntoGroup:userIDs groupID:groupID callback:^(NSArray<ZIMGroupMemberInfo *> * _Nonnull userList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the inviteUsersIntoGroup method is called.
}];
// Send the group invitation.
ZIMGroupInviteApplicationSendConfig config = new ZIMGroupInviteApplicationSendConfig();
config.wording = @"xxx invited you to join the group.";
List<String> userIDs = new ArrList<String>();
userIDs.add("user1");
userIDs.add("user2");
zim.sendGroupInviteApplications(userIDs, "groupID", config, new ZIMGroupInviteApplicationsSentCallback(){
public void onGroupInviteApplicationsSent(String groupID, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo){
// Initiate group invitation result callback.
}
});
// Send the group invitation.
ZIMGroupInviteApplicationSendConfig config = new ZIMGroupInviteApplicationSendConfig();
config.wording = @"xxx invited you to join the group.";
List<String> userIDs = new ArrList<String>();
userIDs.add("user1");
userIDs.add("user2");
zim.sendGroupInviteApplications(userIDs, "groupID", config, new ZIMGroupInviteApplicationsSentCallback(){
public void onGroupInviteApplicationsSent(String groupID, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo){
// Initiate group invitation result callback.
}
});
// Send an invitation to join the group
ZIMGroupInviteApplicationSendConfig config = ZIMGroupInviteApplicationSendConfig();
config.wording = 'xxx invites you to join the group chat';
ZIMGroupInviteApplicationSendConfig applicationSendConfig = ZIMGroupInviteApplicationSendConfig();
try{
var result = await ZIM.getInstance()!.sendGroupInviteApplications(['userID1','userID2'], 'groupID', config);
} on PlatformException catch (onError) {
onError.code;
onError.message;
}
// Send an invitation to join the group
ZIMGroupInviteApplicationSendConfig config = ZIMGroupInviteApplicationSendConfig();
config.wording = 'xxx invites you to join the group chat';
ZIMGroupInviteApplicationSendConfig applicationSendConfig = ZIMGroupInviteApplicationSendConfig();
try{
var result = await ZIM.getInstance()!.sendGroupInviteApplications(['userID1','userID2'], 'groupID', config);
} on PlatformException catch (onError) {
onError.code;
onError.message;
}
// Send an invitation application.
const userIDs = [];
const groupID = '';
const config: ZIMGroupInviteApplicationSendConfig = {
wording: 'Invite to join the group' // Application message.
};
zim.sendGroupInviteApplications(userIDs, groupID, config)
.then(function ({ groupID, errorUserList }) {
// The operation is successful, and the users who failed to invite are obtained through errorUserList.
})
.catch(function (err) {
// Operation failed.
});
// Send an invitation application.
const userIDs = [];
const groupID = '';
const config: ZIMGroupInviteApplicationSendConfig = {
wording: 'Invite to join the group' // Application message.
};
zim.sendGroupInviteApplications(userIDs, groupID, config)
.then(function ({ groupID, errorUserList }) {
// The operation is successful, and the users who failed to invite are obtained through errorUserList.
})
.catch(function (err) {
// Operation failed.
});
// Send the group invitation.
ZIMGroupInviteApplicationSendConfig *config = [[ZIMGroupInviteApplicationSendConfig alloc] init];
config.wording = @"xxx invited you to join the group.";
[zim sendGroupInviteApplicationsToUserIDs:@[@"userID1",@"userID2"] groupID:@"groupID" config:config callback:^(NSString * _Nonnull groupID, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
}];
// Send the group invitation.
ZIMGroupInviteApplicationSendConfig *config = [[ZIMGroupInviteApplicationSendConfig alloc] init];
config.wording = @"xxx invited you to join the group.";
[zim sendGroupInviteApplicationsToUserIDs:@[@"userID1",@"userID2"] groupID:@"groupID" config:config callback:^(NSString * _Nonnull groupID, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
}];
The following table describes the operation results of different methods called by different roles in a group in inviteMode and beInviteMode modes.
beInviteMode
inviteMode
Method
Caller
Result
0: None
0: Any
inviteUsersIntoGroup
All group members
The invitee joins the group without approval.
sendGroupInviteApplicationsToUserIDs
The invitee joins the group without approval, with no application generated.
1: Admin
inviteUsersIntoGroup
Ordinary members
Failed.
Group owner or administrator
The invitee joins the group without approval.
sendGroupInviteApplicationsToUserIDs
Ordinary members
Failed.
Group owner or administrator
The invitee joins the group without approval, with no application generated.
1: Auth
0: Any
inviteUsersIntoGroup
All group members
An application is generated and sent to the invitee for approval.
sendGroupInviteApplicationsToUserIDs
An application is generated and sent to the invitee for approval. If the caller is the group owner or administrator, the groupApplicationListChanged callback is generated.
1: Admin
inviteUsersIntoGroup
Ordinary members
Failed.
Group owner or administrator
An application is generated and sent to the invitee for approval.
An application is generated and sent to the invitee for approval. If the caller is the group owner or administrator, the groupApplicationListChanged callback is generated.
If the beInviteMode is set to 1 (AUTH), the invitee and inviter (the group owner or administrator) receive the notification in the groupApplicationListChanged callback. The invitee can perform the following operations on the application:
// Agree to join the group invitation.
ZIMGroupInviteApplicationAcceptConfig config = new ZIMGroupInviteApplicationAcceptConfig();
zim.acceptGroupInviteApplication("inviterUserID", "groupID", config, new ZIMGroupInviteApplicationAcceptedCallback(){
public void onGroupInviteApplicationAccepted(ZIMGroupFullInfo groupInfo, String inviterUserID, ZIMError errorInfo){
// Callback for agree group invitation result.
}
});
// Agree to join the group invitation.
ZIMGroupInviteApplicationAcceptConfig config = new ZIMGroupInviteApplicationAcceptConfig();
zim.acceptGroupInviteApplication("inviterUserID", "groupID", config, new ZIMGroupInviteApplicationAcceptedCallback(){
public void onGroupInviteApplicationAccepted(ZIMGroupFullInfo groupInfo, String inviterUserID, ZIMError errorInfo){
// Callback for agree group invitation result.
}
});
try{
ZIMGroupInviteApplicationAcceptConfig acceptConfig = ZIMGroupInviteApplicationAcceptConfig();
var result = await ZIM.getInstance()!.acceptGroupInviteApplication('inviterUserID', 'groupID', acceptConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
try{
ZIMGroupInviteApplicationAcceptConfig acceptConfig = ZIMGroupInviteApplicationAcceptConfig();
var result = await ZIM.getInstance()!.acceptGroupInviteApplication('inviterUserID', 'groupID', acceptConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Agree to join the group invitation.
zim::ZIMGroupInviteApplicationAcceptConfig config;
zim_->acceptGroupInviteApplication(
user_id, group_id, config,
[=](const zim::ZIMGroupFullInfo &group, const std::string &inviterUserID,
const zim::ZIMError &errorInfo) {
int error_code = errorInfo.code;
});
// Agree to join the group invitation.
zim::ZIMGroupInviteApplicationAcceptConfig config;
zim_->acceptGroupInviteApplication(
user_id, group_id, config,
[=](const zim::ZIMGroupFullInfo &group, const std::string &inviterUserID,
const zim::ZIMError &errorInfo) {
int error_code = errorInfo.code;
});
// Refuse to join the group invitation.
ZIMGroupInviteApplicationRejectConfig config = new ZIMGroupInviteApplicationRejectConfig();
zim.rejectGroupInviteApplication("inviterUserID", "groupID", config, new ZIMGroupInviteApplicationRejectedCallback(){
public void onGroupInviteApplicationRejected(String groupID, String inviterUserID, ZIMError errorInfo) {
// Reject group invitation result callback.
}
});
// Refuse to join the group invitation.
ZIMGroupInviteApplicationRejectConfig config = new ZIMGroupInviteApplicationRejectConfig();
zim.rejectGroupInviteApplication("inviterUserID", "groupID", config, new ZIMGroupInviteApplicationRejectedCallback(){
public void onGroupInviteApplicationRejected(String groupID, String inviterUserID, ZIMError errorInfo) {
// Reject group invitation result callback.
}
});
try{
ZIMGroupInviteApplicationRejectConfig rejectConfig = ZIMGroupInviteApplicationRejectConfig();
var result = await ZIM.getInstance()!.rejectGroupInviteApplication('inviterUserID', 'groupID', rejectConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
try{
ZIMGroupInviteApplicationRejectConfig rejectConfig = ZIMGroupInviteApplicationRejectConfig();
var result = await ZIM.getInstance()!.rejectGroupInviteApplication('inviterUserID', 'groupID', rejectConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
Refuse to join the group invitation.
zim::ZIMGroupInviteApplicationRejectConfig config;
zim_->rejectGroupInviteApplication(
user_id, group_id, config,
[=](const std::string &groupID, const std::string &inviterUserID,
const zim::ZIMError &errorInfo) {
int error_code = errorInfo.code;
});
Refuse to join the group invitation.
zim::ZIMGroupInviteApplicationRejectConfig config;
zim_->rejectGroupInviteApplication(
user_id, group_id, config,
[=](const std::string &groupID, const std::string &inviterUserID,
const zim::ZIMError &errorInfo) {
int error_code = errorInfo.code;
});
If the beInviteMode is set to 1 (AUTH), the invitee and inviter (the group owner or administrator) receive the approval notification in the groupApplicationUpdated callback.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupApplicationUpdated(ZIM zim,
ArrayList<ZIMGroupApplicationInfo> applicationList) {
// Group application update callback notification. }
});
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupApplicationUpdated(ZIM zim,
ArrayList<ZIMGroupApplicationInfo> applicationList) {
// Group application update callback notification. }
});
// Listen for groupApplicationUpdated event.
zim.on('groupApplicationUpdated', (zim, { applicationList }) => {
// If there is a change in the group application, you can update the group application list UI at this time.
console.log(applicationList);
});
// Listen for groupApplicationUpdated event.
zim.on('groupApplicationUpdated', (zim, { applicationList }) => {
// If there is a change in the group application, you can update the group application list UI at this time.
console.log(applicationList);
});
A group member can leave a group or be removed from a group.
Warning
After a group member leaves a group, the local list of conversations is retained, and historical group messages can be viewed.
Method 1: A group member leaves the group
After logging in to the ZIM SDK, the group member calls the leaveGroup method and passes in the groupID. If the groupID does not exist, the operation fails. After the group member leaves the group, all group members receive the groupMemberStateChanged callback.
Note
If the group owner leaves the group, the group ownership is automatically transferred to the first group member. If all group members leave the group, the group is automatically disbanded.
// Leave a group.
zim.leaveGroup("groupID", new ZIMGroupLeftCallback() {
@Override
public void onGroupLeft(ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// Leave a group.
zim.leaveGroup("groupID", new ZIMGroupLeftCallback() {
@Override
public void onGroupLeft(ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
Developers can use ZIMGroupLeftResult to determine whether the member successfully left the group.
// Voluntarily leave a group
ZIM.getInstance()
!.leaveGroup('groupID')
.then((value){
// Triggered on success
})
.catchError((onError) {
// Triggered on failure
});
// Voluntarily leave a group
ZIM.getInstance()
!.leaveGroup('groupID')
.then((value){
// Triggered on success
})
.catchError((onError) {
// Triggered on failure
});
// Leave a group.
zim_->leaveGroup(group_id, [=](const std::string &groupID, zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});
// Leave a group.
zim_->leaveGroup(group_id, [=](const std::string &groupID, zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});
// Leave a group.
[zim leaveGroup:groupID callback:^(ZIMError * _Nonnull errorInfo) {
// The business logic after the leaveGroup method is called.
}];
// Leave a group.
[zim leaveGroup:groupID callback:^(ZIMError * _Nonnull errorInfo) {
// The business logic after the leaveGroup method is called.
}];
Method 2: The group owner removes a group member from the group
The group owner calls the kickGroupMembers method and passes in the groupID and userIDList (list of users to be removed). If the groupID does not exist, the operation fails. After one or more group members are removed, all group members (including the group owner and the removed group members) receive the groupMemberStateChanged callback.
Developers can use ZIMGroupMemberKickedResult to determine whether the user has been successfully removed.
Warning
Only the group owner or administrator can call the kickGroupMembers method to remove a group member, who does not need to be logged in or approve the removal.
The userID of the user to be removed must be in the list of group members; otherwise, the operation fails.
// The group owner removes one or more group members from the group.
ArrayList<String> user_list = new ArrayList<>();
user_list.add("user_1");
user_list.add("user_2");
zim.kickGroupMembers(user_list, "groupID", new ZIMGroupMemberKickedCallback() {
@Override
public void onGroupMemberKicked(ArrayList<String> kickedUserIDList, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// The group owner removes one or more group members from the group.
ArrayList<String> user_list = new ArrayList<>();
user_list.add("user_1");
user_list.add("user_2");
zim.kickGroupMembers(user_list, "groupID", new ZIMGroupMemberKickedCallback() {
@Override
public void onGroupMemberKicked(ArrayList<String> kickedUserIDList, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// Remove members from the group by the group owner
ZIM.getInstance()
!.kickGroupMembers(userIDs, 'groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// Remove members from the group by the group owner
ZIM.getInstance()
!.kickGroupMembers(userIDs, 'groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// The group owner removes one or more group members from the group.
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->kickGroupMembers(user_list, group_id,
[=](const std::string &groupID, const std::vector<std::string> &kickedMemberIDs,
const std::vector<ZIMErrorUser> &errorUserList, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
// The group owner removes one or more group members from the group.
std::vector<std::string> user_list;
user_list.push_back("user_1");
user_list.push_back("user_2");
zim_->kickGroupMembers(user_list, group_id,
[=](const std::string &groupID, const std::vector<std::string> &kickedMemberIDs,
const std::vector<ZIMErrorUser> &errorUserList, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
const groupID = '';
// The group owner removes one or more group members from the group.
const userIDs = [];
zim.kickGroupMembers(userIDs, groupID)
.then(function ({ groupID, kickedUserIDs, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
const groupID = '';
// The group owner removes one or more group members from the group.
const userIDs = [];
zim.kickGroupMembers(userIDs, groupID)
.then(function ({ groupID, kickedUserIDs, errorUserList }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// The group owner removes one or more group members from the group.
[zim kickGroupMembers:userIDs groupID:groupID callback:^(NSArray<NSString *> * _Nonnull kickedUserIDList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the group owner calls the kickGroupMembers method.
}];
// The group owner removes one or more group members from the group.
[zim kickGroupMembers:userIDs groupID:groupID callback:^(NSArray<NSString *> * _Nonnull kickedUserIDList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
// The business logic after the group owner calls the kickGroupMembers method.
}];
Disband a group
After logging in to the ZIM SDK, the group owner calls the dismissGroup method to disband a group. After the group is disbanded, all group members receive the groupStateChanged callback.
Developers can use ZIMGroupDismissedResult to determine whether the group has been successfully dissolved.
Note
Only the group owner can call the dismissGroup method to disband a group.
If all group members leave a group, the group is automatically disbanded.
After a group is disbanded, the local list of conversations is retained, and historical messages can be viewed.
// The group owner disbands the group.
zim.dismissGroup("groupID", new ZIMGroupDismissedCallback() {
@Override
public void onGroupDismissed(ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// The group owner disbands the group.
zim.dismissGroup("groupID", new ZIMGroupDismissedCallback() {
@Override
public void onGroupDismissed(ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// Dismiss group by group owner
ZIM.getInstance()
.dismissGroup('groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// Dismiss group by group owner
ZIM.getInstance()
.dismissGroup('groupID')
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// The group owner disbands the group.
zim_->dismissGroup(group_id, [=](const std::string &groupID, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
// The group owner disbands the group.
zim_->dismissGroup(group_id, [=](const std::string &groupID, zim::ZIMError errorInfo) {
int error_code = errorInfo.code;
});
// The group owner disbands the group.
[zim dismissGroup:groupID callback:^(ZIMError * _Nonnull errorInfo) {
// The business logic after the dismissGroup method is called.
}];
// The group owner disbands the group.
[zim dismissGroup:groupID callback:^(ZIMError * _Nonnull errorInfo) {
// The business logic after the dismissGroup method is called.
}];
More features
Query the list of joined groups
After logging in to the ZIM SDK, a user calls the queryGroupList method to query the list of joined groups.
// The user queries the list of joined groups.
zim.queryGroupList(new ZIMGroupListQueriedCallback() {
@Override
public void onGroupListQueried(ArrayList<ZIMGroupInfo> groupList, ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// The user queries the list of joined groups.
zim.queryGroupList(new ZIMGroupListQueriedCallback() {
@Override
public void onGroupListQueried(ArrayList<ZIMGroupInfo> groupList, ZIMError errorInfo) {
// Get the result of actively exiting the group through errorInfo.code.
}
});
// User queries the groups they have joined
ZIM.getInstance()
.queryGroupList()
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// User queries the groups they have joined
ZIM.getInstance()
.queryGroupList()
.then((value){
// Triggered when successful
})
.catchError((onError) {
// Triggered when failed
});
// The user queries the list of joined groups.
zim_->queryGroupList(
[=](const std::vector<ZIMGroupInfo> &groupList, zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});
// The user queries the list of joined groups.
zim_->queryGroupList(
[=](const std::vector<ZIMGroupInfo> &groupList, zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});
// The user queries the list of joined groups.
[zim queryGroupListByGroupID:^(NSArray<ZIMGroupInfo *> * _Nonnull groupList, ZIMError * _Nonnull errorInfo) {
// The business logic after the queryGroupListByGroupID method is called.
}];
// The user queries the list of joined groups.
[zim queryGroupListByGroupID:^(NSArray<ZIMGroupInfo *> * _Nonnull groupList, ZIMError * _Nonnull errorInfo) {
// The business logic after the queryGroupListByGroupID method is called.
}];
Search for joined groups
After logging in to the ZIM SDK, a user calls the searchLocalGroupsWithConfig method and passes in the config and callback parameters to search for joined groups by condition.
// Search for joined groups that contain a member named "zego".
ZIM zim = getZIM();
ZIMGroupMemberSearchConfig config = new ZIMGroupMemberSearchConfig();
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the nickname of a group member contains "zego", the group is returned in the search result.
config.isAlsoMatchGroupMemberUserName = true; // If the username of a group member contains "zego", the group is returned in the search result.
config.keywords.add("zego");
zim.searchLocalGroups(config, new ZIMGroupsSearchedCallback() {
@Override
public void onGroupsSearched(ArrayList<ZIMGroupSearchInfo> groupSearchInfoList, int nextFlag, ZIMError errorInfo) {
// You can obtain the group information in the groupSearchInfoList field.
}
});
// Search for joined groups that contain a member named "zego".
ZIM zim = getZIM();
ZIMGroupMemberSearchConfig config = new ZIMGroupMemberSearchConfig();
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the nickname of a group member contains "zego", the group is returned in the search result.
config.isAlsoMatchGroupMemberUserName = true; // If the username of a group member contains "zego", the group is returned in the search result.
config.keywords.add("zego");
zim.searchLocalGroups(config, new ZIMGroupsSearchedCallback() {
@Override
public void onGroupsSearched(ArrayList<ZIMGroupSearchInfo> groupSearchInfoList, int nextFlag, ZIMError errorInfo) {
// You can obtain the group information in the groupSearchInfoList field.
}
});
// Search for joined groups that contain "zego" in the name
ZIMGroupSearchConfig config = ZIMGroupSearchConfig();
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the group member nickname contains "zego", the search result will include that group.
config.isAlsoMatchGroupMemberUserName = true; // If the group member username contains "zego", the search result will include that group.
config.keywords.add("zego");
ZIM.getInstance()!.searchLocalGroups(config).then((result){
// Developers can get the group information from groupSearchInfoList
}).catchError((onError){
// Handle according to the official error code table
});
// Search for joined groups that contain "zego" in the name
ZIMGroupSearchConfig config = ZIMGroupSearchConfig();
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the group member nickname contains "zego", the search result will include that group.
config.isAlsoMatchGroupMemberUserName = true; // If the group member username contains "zego", the search result will include that group.
config.keywords.add("zego");
ZIM.getInstance()!.searchLocalGroups(config).then((result){
// Developers can get the group information from groupSearchInfoList
}).catchError((onError){
// Handle according to the official error code table
});
// Search for joined groups that contain a member named "zego".
auto searchConfig = zim::ZIMGroupSearchConfig();
searchConfig.count = 10;
searchConfig.nextFlag = 0;
// If the nickname of a group member contains "zego", the group is returned in the search result.
searchConfig.isAlsoMatchGroupMemberNickname = true;
// If the username of a group member contains "zego", the group is returned in the search result.
searchConfig.isAlsoMatchGroupMemberUserName = true;
searchConfig.keywords.emplace_back("zego");
zim_->searchLocalGroups(searchConfig,
[=](const std::vector<zim::ZIMGroupSearchInfo> &groupSearchInfoList,
unsigned int nextFlag, const zim::ZIMError &errorInfo) {
// You can obtain the group information in the groupSearchInfoList field.
});
// Search for joined groups that contain a member named "zego".
auto searchConfig = zim::ZIMGroupSearchConfig();
searchConfig.count = 10;
searchConfig.nextFlag = 0;
// If the nickname of a group member contains "zego", the group is returned in the search result.
searchConfig.isAlsoMatchGroupMemberNickname = true;
// If the username of a group member contains "zego", the group is returned in the search result.
searchConfig.isAlsoMatchGroupMemberUserName = true;
searchConfig.keywords.emplace_back("zego");
zim_->searchLocalGroups(searchConfig,
[=](const std::vector<zim::ZIMGroupSearchInfo> &groupSearchInfoList,
unsigned int nextFlag, const zim::ZIMError &errorInfo) {
// You can obtain the group information in the groupSearchInfoList field.
});
// Search for joined groups with names containing "zego".
const config: ZIMGroupSearchConfig = {
count: 10, // Number of search results.
nextFlag: 0,
keywords: ['zego'], // Set the keyword to "zego", up to 5 keywords are supported. When multiple keywords are set, the search results will only display local messages that contain all keywords at the same time.
isAlsoMatchGroupMemberUserName: true, // If the group member user name contains "zego", the search results will include the group member
isAlsoMatchGroupMemberNickname: false,
};
zim.searchLocalGroups(config)
.then(function ({ groupSearchInfoList, nextFlag }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Search for joined groups with names containing "zego".
const config: ZIMGroupSearchConfig = {
count: 10, // Number of search results.
nextFlag: 0,
keywords: ['zego'], // Set the keyword to "zego", up to 5 keywords are supported. When multiple keywords are set, the search results will only display local messages that contain all keywords at the same time.
isAlsoMatchGroupMemberUserName: true, // If the group member user name contains "zego", the search results will include the group member
isAlsoMatchGroupMemberNickname: false,
};
zim.searchLocalGroups(config)
.then(function ({ groupSearchInfoList, nextFlag }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Search for joined groups that contain a member named "zego".
ZIMGroupSearchConfig *config = [[ZIMGroupSearchConfig alloc] init];
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the nickname of a group member contains "zego", the group is returned in the search result.
config.isAlsoMatchGroupMemberUserName = true; // If the username of a group member contains "zego", the group is returned in the search result.
config.keywords = @[@"zego"];
[[ZIM getInstance] searchLocalGroupsWithConfig:config callback:^(NSArray<ZIMGroupSearchInfo *> * _Nonnull groupSearchInfoList, unsigned int nextFlag, ZIMError * _Nonnull errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess){
// You can obtain the group information in the groupSearchInfoList field.
}else{
// Handle the error based on the error code table.
}
}];
// Search for joined groups that contain a member named "zego".
ZIMGroupSearchConfig *config = [[ZIMGroupSearchConfig alloc] init];
config.count = 10;
config.nextFlag = 0;
config.isAlsoMatchGroupMemberNickname = true; // If the nickname of a group member contains "zego", the group is returned in the search result.
config.isAlsoMatchGroupMemberUserName = true; // If the username of a group member contains "zego", the group is returned in the search result.
config.keywords = @[@"zego"];
[[ZIM getInstance] searchLocalGroupsWithConfig:config callback:^(NSArray<ZIMGroupSearchInfo *> * _Nonnull groupSearchInfoList, unsigned int nextFlag, ZIMError * _Nonnull errorInfo) {
if(errorInfo.code == ZIMErrorCodeSuccess){
// You can obtain the group information in the groupSearchInfoList field.
}else{
// Handle the error based on the error code table.
}
}];
Mute or unmute a group
If a group is muted, group members cannot send messages to the group.
After logging in to the ZIM SDK, a user can mute or unmute a group on which the user has management permission by calling the muteGroup method and passing in parameters to specify the group ID, mute mode, duration, and role.
The ZIM SDK supports three mute modes:
All group members are muted.
All ordinary group members (whose role value is 3) are muted.
// Configure group muting.
ZIMGroupMuteConfig config = new ZIMGroupMuteConfig();
// Group members of specified roles are muted.
config.mode = ZIMGroupMuteMode.Custom;
// These members are muted for 30 seconds.
config.duration = 30;
// Group members whose `role` value is `3` or `5` are muted.
config.roles.add(3);
config.roles.add(5);
// Enable muting
boolean isMute = true;
zim.muteGroup(isMute, "group_id", config, new ZIMGroupMutedCallback() {
@Override
public void onGroupMuted(String groupID, boolean isMute, ZIMGroupMuteInfo info, ZIMError errorInfo) {
}
});
// Configure group muting.
ZIMGroupMuteConfig config = new ZIMGroupMuteConfig();
// Group members of specified roles are muted.
config.mode = ZIMGroupMuteMode.Custom;
// These members are muted for 30 seconds.
config.duration = 30;
// Group members whose `role` value is `3` or `5` are muted.
config.roles.add(3);
config.roles.add(5);
// Enable muting
boolean isMute = true;
zim.muteGroup(isMute, "group_id", config, new ZIMGroupMutedCallback() {
@Override
public void onGroupMuted(String groupID, boolean isMute, ZIMGroupMuteInfo info, ZIMError errorInfo) {
}
});
// Set the group mute configuration
try {
// Set the group mute configuration
ZIMGroupMuteConfig config = ZIMGroupMuteConfig();
// Set the mute mode to mute group members with specified roles
config.mode = ZIMGroupMuteMode.custom;
// Set the mute duration to 30 seconds
config.duration = 30;
// Mute group members with roles 3 and 5
config.roles = [3,5];
// Enable mute
bool isMute = true;
ZIMGroupMutedResult result = await ZIM.getInstance()!.muteGroup(isMute, 'group_id', config);
} on PlatformException catch (onError){
onError.code;// Handle according to the error code table
onError.message;// Error message
}
// Set the group mute configuration
try {
// Set the group mute configuration
ZIMGroupMuteConfig config = ZIMGroupMuteConfig();
// Set the mute mode to mute group members with specified roles
config.mode = ZIMGroupMuteMode.custom;
// Set the mute duration to 30 seconds
config.duration = 30;
// Mute group members with roles 3 and 5
config.roles = [3,5];
// Enable mute
bool isMute = true;
ZIMGroupMutedResult result = await ZIM.getInstance()!.muteGroup(isMute, 'group_id', config);
} on PlatformException catch (onError){
onError.code;// Handle according to the error code table
onError.message;// Error message
}
// Configure group muting.
zim::ZIMGroupMuteConfig config;
// Group members of specified roles are muted.
config.mode = zim::ZIMGroupMuteMode::ZIM_GROUP_MUTE_MODE_CUSTOM;
// These members are muted for 30 seconds.
config.duration = 30;
// Group members whose `role` value is `2` or `3` are muted.
config.roles.push_back(2);
config.roles.push_back(3);
// Enable muting
bool is_mute = true;
zim_->muteGroup(is_mute, group_id, config,
[=](const std::string &groupID, bool is_muted,
const zim::ZIMGroupMuteInfo &info,
const zim::ZIMError &errorInfo) {
// Developers can get group muting information from info
});
// Configure group muting.
zim::ZIMGroupMuteConfig config;
// Group members of specified roles are muted.
config.mode = zim::ZIMGroupMuteMode::ZIM_GROUP_MUTE_MODE_CUSTOM;
// These members are muted for 30 seconds.
config.duration = 30;
// Group members whose `role` value is `2` or `3` are muted.
config.roles.push_back(2);
config.roles.push_back(3);
// Enable muting
bool is_mute = true;
zim_->muteGroup(is_mute, group_id, config,
[=](const std::string &groupID, bool is_muted,
const zim::ZIMGroupMuteInfo &info,
const zim::ZIMError &errorInfo) {
// Developers can get group muting information from info
});
// Configure group muting.
const config: ZIMGroupMuteConfig = {
mode: 3, //Group members of specified roles are muted.
duration: 30, //hese members are muted for 30 seconds.
roles:[3, 5],//Group members whose `role` value is `3` or `5` are muted.
};
// Enable muting
const isMute = true;
const groupID = 'group';
zim.muteGroup(isMute, groupID, config)
.then(function ({ groupID, isMute, mutedInfo }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Configure group muting.
const config: ZIMGroupMuteConfig = {
mode: 3, //Group members of specified roles are muted.
duration: 30, //hese members are muted for 30 seconds.
roles:[3, 5],//Group members whose `role` value is `3` or `5` are muted.
};
// Enable muting
const isMute = true;
const groupID = 'group';
zim.muteGroup(isMute, groupID, config)
.then(function ({ groupID, isMute, mutedInfo }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Configure group muting.
ZIMGroupMuteConfig *muteConfig = [[ZIMGroupMuteConfig alloc] init];
// Group members of specified roles are muted.
muteConfig.mode = ZIMGroupMuteModeCustom;
// These members are muted for 30 seconds.
muteConfig.duration = 30;
// Group members whose `role` value is `3` or `5` are muted.
muteConfig.roles = @[@3,@5];
[[ZIM getInstance] muteGroup:YES groupID:@"groupID" config:muteConfig callback:^(NSString * _Nonnull groupID, BOOL isMute, ZIMGroupMuteInfo * _Nonnull info, ZIMError * _Nonnull errorInfo) {
// You can obtain the group muting information in the `info` field.
}];
// Configure group muting.
ZIMGroupMuteConfig *muteConfig = [[ZIMGroupMuteConfig alloc] init];
// Group members of specified roles are muted.
muteConfig.mode = ZIMGroupMuteModeCustom;
// These members are muted for 30 seconds.
muteConfig.duration = 30;
// Group members whose `role` value is `3` or `5` are muted.
muteConfig.roles = @[@3,@5];
[[ZIM getInstance] muteGroup:YES groupID:@"groupID" config:muteConfig callback:^(NSString * _Nonnull groupID, BOOL isMute, ZIMGroupMuteInfo * _Nonnull info, ZIMError * _Nonnull errorInfo) {
// You can obtain the group muting information in the `info` field.
}];
After a group is muted or unmuted, all group members receive the groupMutedInfoUpdated callback and know which roles are muted or unmuted.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupMutedInfoUpdated(ZIM zim, ZIMGroupMuteInfo muteInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
});
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupMutedInfoUpdated(ZIM zim, ZIMGroupMuteInfo muteInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
});
ZIMEventHandler.onGroupMutedInfoUpdated = (ZIM zim, ZIMGroupMuteInfo groupMuteInfo, ZIMGroupOperatedInfo operatedInfo, String groupID){
// Listen to the information of group mute status changes here and handle accordingly
};
ZIMEventHandler.onGroupMutedInfoUpdated = (ZIM zim, ZIMGroupMuteInfo groupMuteInfo, ZIMGroupOperatedInfo operatedInfo, String groupID){
// Listen to the information of group mute status changes here and handle accordingly
};
void zim_event_handler::onGroupMutedInfoUpdated(zim::ZIM *, const zim::ZIMGroupMuteInfo &info,
const zim::ZIMGroupOperatedInfo &operatedInfo,
const std::string &groupID) {
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
});
void zim_event_handler::onGroupMutedInfoUpdated(zim::ZIM *, const zim::ZIMGroupMuteInfo &info,
const zim::ZIMGroupOperatedInfo &operatedInfo,
const std::string &groupID) {
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
});
- (void)zim:(ZIM *)zim
groupMutedInfoUpdated:(ZIMGroupMuteInfo *)muteInfo
operatedInfo:(ZIMGroupOperatedInfo *)operatedInfo
groupID:(NSString *)groupID{
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
- (void)zim:(ZIM *)zim
groupMutedInfoUpdated:(ZIMGroupMuteInfo *)muteInfo
operatedInfo:(ZIMGroupOperatedInfo *)operatedInfo
groupID:(NSString *)groupID{
// Listen for the group muting status change and handle the change by inheriting the ZIMEventHandler method.
}
Check whether a user is in a group
To check whether a user is in a group, call any of the following methods:
true: The user is not in the group. If the user leaves the group or is removed from the group, or the group is disbanded, the value of isDisabled is false.
false: The user is in the group.
Update the group joining mode
After logging in to the ZIM SDK, the group owner or administrator calls the updateGroupJoinMode method to update the group joining mode.
After the mode is updated, all group members receive the groupVerifyInfoUpdated callback.
// Listen for onGroupVerifyInfoUpdated event.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupVerifyInfoUpdated(ZIM zim, ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Update joinMode of a group.
}
});
// Update the verification mode for others to join the group
zim.updateGroupJoinMode(ZIMGroupJoinMode.AUTH, "groupID", new ZIMGroupJoinModeUpdatedCallback(){
public void onGroupJoinModeUpdated(String groupID, ZIMGroupJoinMode mode, ZIMError errorInfo){
// Update verification mode result callback notification
}
});
// Listen for onGroupVerifyInfoUpdated event.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupVerifyInfoUpdated(ZIM zim, ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Update joinMode of a group.
}
});
// Update the verification mode for others to join the group
zim.updateGroupJoinMode(ZIMGroupJoinMode.AUTH, "groupID", new ZIMGroupJoinModeUpdatedCallback(){
public void onGroupJoinModeUpdated(String groupID, ZIMGroupJoinMode mode, ZIMError errorInfo){
// Update verification mode result callback notification
}
});
// Listen to the onGroupVerifyInfoUpdated event
ZIMEventHandler.onGroupVerifyInfoUpdated = (ZIM zim,
ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo,
String groupID){};
// Update the group join mode
try{
var result = await ZIM.getInstance()!.updateGroupJoinMode(ZIMGroupJoinMode.auth, 'groupID');
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Listen to the onGroupVerifyInfoUpdated event
ZIMEventHandler.onGroupVerifyInfoUpdated = (ZIM zim,
ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo,
String groupID){};
// Update the group join mode
try{
var result = await ZIM.getInstance()!.updateGroupJoinMode(ZIMGroupJoinMode.auth, 'groupID');
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Update the verification mode for inviting others to join the group
zim_->updateGroupJoinMode(
zim::ZIMGroupJoinMode::ZIM_GROUP_JOIN_MODE_AUTH, group_id,
[=](const std::string &groupID, zim::ZIMGroupJoinMode mode,
const zim::ZIMError &errorInfo) {
// Business code
});
// Update the verification mode for inviting others to join the group
zim_->updateGroupJoinMode(
zim::ZIMGroupJoinMode::ZIM_GROUP_JOIN_MODE_AUTH, group_id,
[=](const std::string &groupID, zim::ZIMGroupJoinMode mode,
const zim::ZIMError &errorInfo) {
// Business code
});
// Listen for groupVerifyInfoUpdated event.
zim.on('groupVerifyInfoUpdated', (zim, { groupID, verifyInfo, operatedInfo }) => {
console.log(groupID, verifyInfo.joinMode);
});
// Update the verification mode for others to join the group
const groupID = '';
const joinMode = 1;
zim.updateGroupJoinMode(joinMode, groupID)
.then(function ({ groupID, mode }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Listen for groupVerifyInfoUpdated event.
zim.on('groupVerifyInfoUpdated', (zim, { groupID, verifyInfo, operatedInfo }) => {
console.log(groupID, verifyInfo.joinMode);
});
// Update the verification mode for others to join the group
const groupID = '';
const joinMode = 1;
zim.updateGroupJoinMode(joinMode, groupID)
.then(function ({ groupID, mode }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
After logging in to the ZIM SDK, the group owner or administrator calls the updateGroupBeInviteMode method to update beInviteMode.
After the mode is updated, all group members receive the groupVerifyInfoUpdated callback.
// Listen for onGroupVerifyInfoUpdated event.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupVerifyInfoUpdated(ZIM zim, ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Invite mode update callback notification.
}
});
// Update beInviteMode.
zim.updateGroupInviteMode(ZIMGroupInviteMode.ADMIN, "groupID", new ZIMGroupInviteModeUpdatedCallback(){
public void onGroupInviteModeUpdated(String groupID, ZIMGroupInviteMode mode, ZIMError errorInfo){
// Update the callback notification of the verification mode result of inviting others to join the group.
}
});
// Listen for onGroupVerifyInfoUpdated event.
zim.setEventHandler(new ZIMEventHandler(){
public void onGroupVerifyInfoUpdated(ZIM zim, ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo, String groupID) {
// Invite mode update callback notification.
}
});
// Update beInviteMode.
zim.updateGroupInviteMode(ZIMGroupInviteMode.ADMIN, "groupID", new ZIMGroupInviteModeUpdatedCallback(){
public void onGroupInviteModeUpdated(String groupID, ZIMGroupInviteMode mode, ZIMError errorInfo){
// Update the callback notification of the verification mode result of inviting others to join the group.
}
});
// Listen to the onGroupVerifyInfoUpdated event
ZIMEventHandler.onGroupVerifyInfoUpdated = (ZIM zim,
ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo,
String groupID){};
// Update the mode for verifying the target user when being invited to a group
try{
var result = await ZIM.getInstance()!.updateGroupBeInviteMode(ZIMGroupBeInviteMode.auth, 'groupID');
} on PlatformException catch(onError){
onError.code;
onError.message;
}
// Listen to the onGroupVerifyInfoUpdated event
ZIMEventHandler.onGroupVerifyInfoUpdated = (ZIM zim,
ZIMGroupVerifyInfo verifyInfo,
ZIMGroupOperatedInfo operatedInfo,
String groupID){};
// Update the mode for verifying the target user when being invited to a group
try{
var result = await ZIM.getInstance()!.updateGroupBeInviteMode(ZIMGroupBeInviteMode.auth, 'groupID');
} on PlatformException catch(onError){
onError.code;
onError.message;
}
After logging in to the ZIM SDK, a user calls the queryGroupApplicationListWithConfig method to query the list of group joining applications. The query result contains applications sent to the user.from and to the user.
ZIMGroupApplicationListQueryConfig config = new ZIMGroupApplicationListQueryConfig();
config.count = 10;
// Fill in 0 for the first query.
conifg.nextFlag = 0;
zim.queryGroupApplicationList(config, new ZIMGroupApplicationListQueriedCallback() {
public void onGroupApplicationListQueried(ArrayList<ZIMGroupApplicationInfo> applicationList, int nextFlag, ZIMError errorInfo) {
// Query group application list result callback.
}
})
ZIMGroupApplicationListQueryConfig config = new ZIMGroupApplicationListQueryConfig();
config.count = 10;
// Fill in 0 for the first query.
conifg.nextFlag = 0;
zim.queryGroupApplicationList(config, new ZIMGroupApplicationListQueriedCallback() {
public void onGroupApplicationListQueried(ArrayList<ZIMGroupApplicationInfo> applicationList, int nextFlag, ZIMError errorInfo) {
// Query group application list result callback.
}
})
try{
ZIMGroupApplicationListQueryConfig queryConfig = ZIMGroupApplicationListQueryConfig();
queryConfig.count = 100;
queryConfig.nextFlag = 0;
var result = await ZIM.getInstance()!.queryGroupApplicationList(queryConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
try{
ZIMGroupApplicationListQueryConfig queryConfig = ZIMGroupApplicationListQueryConfig();
queryConfig.count = 100;
queryConfig.nextFlag = 0;
var result = await ZIM.getInstance()!.queryGroupApplicationList(queryConfig);
} on PlatformException catch(onError){
onError.code;
onError.message;
}
zim::ZIMGroupApplicationListQueryConfig config;
config.count = 100;
config.nextFlag = 0;
zim_->queryGroupApplicationList(
config, [=](const std::vector<zim::ZIMGroupApplicationInfo> &applicationList,
unsigned long long nextFlag, const zim::ZIMError &errorInfo) {
// Business code
});
zim::ZIMGroupApplicationListQueryConfig config;
config.count = 100;
config.nextFlag = 0;
zim_->queryGroupApplicationList(
config, [=](const std::vector<zim::ZIMGroupApplicationInfo> &applicationList,
unsigned long long nextFlag, const zim::ZIMError &errorInfo) {
// Business code
});
// Query the group application list.
const config: ZIMGroupApplicationListQueryConfig = {
count: 30, // Single query number.
nextFlag: 0 // Anchor point, fill in 0 for the first query, and use the nextFlag returned by the current query as the anchor point for the next query.
};
zim.queryGroupApplicationList(config)
.then(function ({ nextFlag, applicationList }) {
// Operation successful, use nextFlag as the anchor point for the next query.
})
.catch(function (err) {
// Operation failed.
});
// Query the group application list.
const config: ZIMGroupApplicationListQueryConfig = {
count: 30, // Single query number.
nextFlag: 0 // Anchor point, fill in 0 for the first query, and use the nextFlag returned by the current query as the anchor point for the next query.
};
zim.queryGroupApplicationList(config)
.then(function ({ nextFlag, applicationList }) {
// Operation successful, use nextFlag as the anchor point for the next query.
})
.catch(function (err) {
// Operation failed.
});