Manage group properties
ZEGOCLOUD's In-app Chat (the ZIM SDK) provides the capability of group properties management, allowing you to customize the group properties and fields, such as the group profile, group status, and more.
- Before you use this feature, you must join a group first. To join a group, refer to the Chapter Join a group of Manage groups.
- All in-group members (group owner included) can use this feature.
Set group properties
To set group properties after joining a group, call the setGroupAttributes method.
The group properties you set are stored as key-value
.
- When Key does not exist: Setting group property means adding room property.
- When the Key already exists: Setting the group property means updating the value of the existing room property.
- Leaves the
Key-Value
empty means no group properties to be set.
- Up to 10 group properties can be set in a group. The group property is stored in the format of
Key-Value
. For more customizable group properties, contact ZEGOCLOUD Technical Support. - The customized group properties you set will be cleared after the group is destroyed.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the group properties set successfully.
// Set group properties.
std::unordered_map<std::string, std::string> attributes;
attributes.emplace("2", "0");
attributes.emplace("3", "0");
attributes.emplace("4", "0");
zim_->setGroupAttributes(attributes, group_id,
[=] (const std::string &groupID, std::vector<std::string> &errorKeys, ZIMError errorInfo){
int error_code = errorInfo.code;
});
Delete group properties
To delete group properties after joining a group, call the deleteGroupAttributes method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the group properties are deleted successfully.
// Delete group properties
std::vector<std::string> keys;
keys.push_back("key_0");
keys.push_back("key_1");
keys.push_back("key_2");
zim_->deleteGroupAttributes(keys, group_id,
[=] (const std::string &groupID, std::vector<std::string> &errorKeys, ZIMError errorInfo){
int error_code = errorInfo.code;
});
Get a group property
To query a group property after joining a group, call the queryGroupAttributes method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the query succeeds.
// Get a group property
std::vector<std::string> keys;
keys.push_back("0");
keys.push_back("1");
keys.push_back("2");
keys.push_back("3");
keys.push_back("4");
keys.push_back("5");
zim_->queryGroupAttributes(keys, group_id,
[=](const std::string &groupID, std::unordered_map<std::string, std::string> &groupAttributes,
zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});
Get all group properties
To query all group properties after joining a group, call the queryGroupAllAttributes method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the query succeeds.
// Get all group properties.
zim_->queryGroupAllAttributes(group_id,
[=](const std::string &groupID, std::unordered_map<std::string, std::string> &groupAttributes,
zim::ZIMError errorInfo){
int error_code = errorInfo.code;
});