Manage group properties
This document is applicable to the following platforms of Unity framework: iOS, Android, macOS, and Windows.
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.
HashMap<String, String> attributes = new HashMap<>();
attributes.put("2", "0");
attributes.put("3", "0");
attributes.put("4", "0");
zim.setGroupAttributes(attributes, group_id, new ZIMGroupAttributesOperatedCallback() {
@Override
public void onGroupAttributesOperated(ArrayList<String> errorKeys, ZIMError errorInfo) {
}
});
1
// Set group properties.
[zim setGroupAttributes:newAttributes groupID:groupID callback:^(NSString * _Nonnull groupID, NSArray<NSString *> * _Nonnull errorKeys, ZIMError * _Nonnull errorInfo) {
//Implement the event callback for setting the group properties here.
}];
1
// Set group properties.
var groupID = '';
var groupAttributes = { key1: 'value1', key2: 'value2' };
zim.setGroupAttributes(groupAttributes, groupID)
.then(function ({ groupID, errorKeys }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Set up and listen for the callback groupAttributesUpdated.
zim.on('groupAttributesUpdated', function (zim, { groupID, infoList, operatedInfo }) {
console.log('groupAttributesUpdated', groupID, infoList, operatedInfo);
});
1
// 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;
});
1
// Set group properties.
Map<String, String> groupAttributes = {'key': 'value'};
ZIM
.getInstance()
.setGroupAttributes(groupAttributes, 'groupID')
.then((value) {
//This will be triggered when operation successful.
})
.catchError((onError) {
//This will be triggered when operation failed.
});
1
// Group members set group attributes
Dictionary<string, string> attributes = new Dictionary<string, string>();
attributes.Add("2", "0");
attributes.Add("3", "0");
attributes.Add("4", "0");
ZIM.GetInstance().SetGroupAttributes(attributes, "group_id", (string groupID, List<string> errorKeys,
ZIMError errorInfo) =>
{
// Use errorInfo.code to get the result of setting group attributes
}
);
1
Delete group properties
To delete group properties after joining a group, call the deleteGroupAttributesByKeys method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the group properties are deleted successfully.
// Delete group properties
ArrayList<String> keys = new ArrayList<>();
keys.add("key_0");
keys.add("key_1");
keys.add("key_2");
zim.deleteGroupAttributes(keys, group_id, new ZIMGroupAttributesOperatedCallback() {
@Override
public void onGroupAttributesOperated(ArrayList<String> errorKeys, ZIMError errorInfo) {
}
});
1
// Delete group properties
[zim deleteGroupAttributesByKeys:deleteAttributesKeys groupID:groupID callback:^(NSString * _Nonnull groupID, NSArray<NSString *> * _Nonnull errorKeys, ZIMError * _Nonnull errorInfo) {
//Implement the event callback for deleting the group properties here.
}];
1
// Delete group properties.
var groupID = '';
var keys = ['key1'];
zim.deleteGroupAttributes(keys, groupID)
.then(function ({ groupID, errorKeys }) {
// Operation successful.
})
.catch(function (err) {
// Operation failed.
});
// Set up and listen for the callback groupAttributesUpdated.
zim.on('groupAttributesUpdated', function (zim, { groupID, infoList, operatedInfo }) {
console.log('groupAttributesUpdated', groupID, infoList, operatedInfo);
});
1
// 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;
});
1
// Delete group properties
List<String> keys = ['key1', 'key2'];
ZIM
.getInstance()
.deleteGroupAttributes(keys, 'groupID')
.then((value) {
//This will be triggered when operation successful.
})
.catchError((onError) {
//This will be triggered when operation failed.
});
1
// Group members delete group attributes
List<string> keys = new List<string>();
keys.Add("key_0");
keys.Add("key_1");
keys.Add("key_2");
ZIM.GetInstance().DeleteGroupAttributes(keys, "group_id", (string groupID, List<string> errorKeys,
ZIMError errorInfo) =>
{
// Use errorInfo.code to get the result of deleting group attributes
}
);
1
Get a group property
To query a group property after joining a group, call the queryGroupAttributesByKeys method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the query succeeds.
// Get a group property
ArrayList<String> keys = new ArrayList<>();
keys.add("0");
keys.add("1");
keys.add("2");
keys.add("3");
keys.add("4");
keys.add("5");
zim.queryGroupAttributes(keys, group_id, new ZIMGroupAttributesQueriedCallback() {
@Override
public void onGroupAttributesQueried(HashMap<String, String> groupAttributes, ZIMError errorInfo) {
}
});
1
// Get a group property
[zim queryGroupAttributesByKeys:attributesKeys groupID:groupID callback:^(NSString * _Nonnull groupID, NSDictionary<NSString *,NSString *> * _Nonnull groupAttributes, ZIMError * _Nonnull errorInfo) {
//Implement the event callback for querying the group property here.
}];
1
// Get a group property.
var groupID = '';
var keys = ['key1'];
zim.queryGroupAttributes(keys, groupID)
.then(function ({ groupID, groupAttributes }) {
// Query successful.
})
.catch(function (err) {
// Query failed.
});
1
// 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;
});
1
// Get a group property
ZIM
.getInstance()
.queryGroupAttributes(keys, 'groupID')
.then((value) {
//This will be triggered when operation successful.
})
.catchError((onError) {
//This will be triggered when operation failed.
});
1
// Group members query group attributes
List<string> keys = new List<string>();
keys.Add("0");
keys.Add("1");
keys.Add("2");
keys.Add("3");
keys.Add("4");
keys.Add("5");
ZIM.GetInstance().QueryGroupAttributes(keys, "group_id", (string groupID, Dictionary<string, string> groupAttributes,
ZIMError errorInfo) =>
{
// Use errorInfo.code to get the result of querying group attributes
}
);
1
Get all group properties
To query all group properties after joining a group, call the queryGroupAllAttributesByGroupID method.
You can receive a notification through the callback ZIMGroupAttributesOperatedCallback after the query succeeds.
// Get all group properties.
zim.queryGroupAttributes(group_id, new ZIMGroupAttributesQueriedCallback() {
@Override
public void onGroupAttributesQueried(HashMap<String, String> groupAttributes, ZIMError errorInfo) {
}
});
1
// Get all group properties.
[zim queryGroupAllAttributes:groupID callback:^(NSString * _Nonnull groupID, NSDictionary<NSString *,NSString *> * _Nonnull groupAttributes, ZIMError * _Nonnull errorInfo) {
//Implement the event callback for querying all group properties here.
}];
1
// Get all group properties.
var groupID = '';
zim.queryGroupAllAttributes(groupID)
.then(function ({ groupID, groupAttributes }) {
// Query successful.
})
.catch(function (err) {
// Query failed.
});
1
// 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;
});
1
// Get all group properties.
ZIM
.getInstance()
.queryGroupAllAttributes('groupID')
.then((value) {
//This will be triggered when operation successful.
})
.catchError((onError) {
//This will be triggered when operation failed.
});
1
// Group members query all group attributes
ZIM.GetInstance().QueryGroupAllAttributes("group_id", (string groupID, Dictionary<string, string> groupAttributes,
ZIMError errorInfo) =>
{
// Use errorInfo.code to get the result of querying group attributes
}
);
1