logo
On this page

Manage group properties


Note

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.

Warning
  • 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.
Warning
  • 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.

SampleCode
// 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
Copied!

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.

SampleCode
// 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
Copied!

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.

SampleCode
// 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
Copied!

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.

SampleCode
// 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
Copied!

Previous

Manage group info

Next

Manage group members