getGroupAttributes
to pull the latest group attributes before you initiate the modification operation again.getGroupAttributes
to update the locally stored group attributes to the latest before you initiate the modification operation.joinGroup
API to join the audio-video group. For a public group (Public), meeting group (Meeting), work group (Work), and community group (Community), you do not need to join the group again.GROUP_ATTRIBUTES_UPDATED
event.chat.initGroupAttributes(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
groupAttributes | Object | Group attributes |
Promise
let promise = chat.initGroupAttributes({groupID: 'group1',groupAttributes: { key1: 'value1', key2: 'value2' }});promise.then(function(imResponse) {console.log(imResponse.data.groupAttributes); // Group attributes initialized successfully}).catch(function(imError) {console.warn('initGroupAttributes error:', imError); // Error information});
chat.setGroupAttributes(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
groupAttributes | Object | Group attributes |
Promise
let promise = chat.setGroupAttributes({groupID: 'group1',groupAttributes: { key1: 'value1', key2: 'value2' }});promise.then(function(imResponse) { // Set successfullyconsole.log(imResponse.data.groupAttributes); // Group attributes set successfully}).catch(function(imError) { // Setting failedconsole.warn('setGroupAttributes error:', imError); // Error information});
keyList
. To delete all group attributes, pass in an empty array for keyList
.chat.deleteGroupAttributes(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
keyList | Array | List of keys of the group attributes |
Promise
// Delete the `key-value` of the specified group attributeslet promise = chat.deleteGroupAttributes({groupID: 'group1',keyList: ['key1', 'key2']});promise.then(function(imResponse) {console.log(imResponse.data.keyList); // List of group attributes deleted successfully}).catch(function(imError) {console.warn('deleteGroupAttributes error:', imError); // Error information});
// Delete all group attributeslet promise = chat.deleteGroupAttributes({groupID: 'group1',keyList: []});promise.then(function(imResponse) {console.log(imResponse.data.keyList); // List of group attributes deleted successfully}).catch(function(imError) {console.warn('deleteGroupAttributes error:', imError); // Error information});
keyList
. To get all group attributes, pass in an empty array for keyList
.chat.getGroupAttributes(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
keyList | Array | List of keys of the group attributes |
Promise
// Get specified group attributeslet promise = chat.getGroupAttributes({groupID: 'group1',keyList: ['key1', 'key2']});promise.then(function(imResponse) { // Got successfullyconsole.log(imResponse.data.groupAttributes); // Specified group attributes}).catch(function(imError) { // Getting failedconsole.warn('getGroupAttributes error:', imError); // Error information});
// Get all group attributeslet promise = chat.getGroupAttributes({groupID: 'group1',keyList: []});promise.then(function(imResponse) { // Got successfullyconsole.log(imResponse.data.groupAttributes); // All group attributes}).catch(function(imError) { // Getting failedconsole.warn('getGroupAttributes error:', imError); // Error information});
let onGroupAttributesUpdated = function(event) {const groupID = event.data.groupID // Group IDconst groupAttributes = event.data.groupAttributes //Updated group propertiesconsole.log(event.data);};chat.on(TencentCloudChat.EVENT.GROUP_ATTRIBUTES_UPDATED, onGroupAttributesUpdated);
Was this page helpful?