ITUIGroupService

ITUIGroupService

Methods

switchGroup(groupID) → {void}

Switch group

Example
// Switch to group1
let promise = TUIGroupService.switchGroup('group1');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupID String

Group ID

Returns:
Type
void

getGroupProfile(options) → {Promise.<any>}

Get group detailed profile

Example
let promise = TUIGroupService.getGroupProfile({
  groupID: 'group1',
  groupCustomFieldFilter: ['key1','key2']
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options GetGroupProfileParams

Parameters for getting group detailed profile

Returns:
Type
Promise.<any>

updateGroupProfile(options) → {Promise.<any>}

Update group detailed profile

Examples
let promise = TUIGroupService.updateGroupProfile({
  groupID: 'group1',
  name: 'new name', // Modify group name
  introduction: 'this is introduction.', // Modify group introduction
  groupCustomField: [{ key: 'group_level', value: 'high'}] // Modify group dimension custom fields
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
let promise = TUIGroupService.updateGroupProfile({
  groupID: 'group1',
  muteAllMembers: true, // true means mute all members, false means cancel mute all members
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options UpdateGroupParams

Parameters for updating group detailed profile

Returns:
Type
Promise.<any>

createGroup(options) → {Promise.<any>}

Create group

Example
let promise = TUIGroupService.createGroup({
  type: TUIChatEngine.TYPES.GRP_WORK,
  name: 'newGroup',
  memberList: [{
    userID: 'user1',
    // Custom fields at group member dimension, not available by default, needs to be enabled, see custom fields for details
    memberCustomField: [{key: 'group_member_test', value: 'test'}]
  }, {
   userID: 'user2'
  }] // If memberList is provided, userID must be provided
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options CreateGroupParams

Parameters for creating group

Returns:
Type
Promise.<any>

dismissGroup(groupID) → {Promise.<any>}

Dismiss group

Example
let promise = TUIGroupService.dismissGroup('group1');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupID string

Group ID

Returns:
Type
Promise.<any>

searchGroupByID(groupID) → {Promise.<any>}

Search group by groupID

Example
let promise = TUIGroupService.searchGroupByID('group1');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupID string

Group ID

Returns:
Type
Promise.<any>

joinGroup(options) → {Promise.<any>}

Apply to join group

Example
let promise = TUIGroupService.joinGroup({
  groupID: 'group1',
  applyMessage: 'xxxx'
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options JoinGroupParams

Parameters for joining group

Returns:
Type
Promise.<any>

quitGroup(groupID) → {Promise.<any>}

Quit group

Example
let promise = TUIGroupService.quitGroup('group1');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupID string

Group ID

Returns:
Type
Promise.<any>

getGroupApplicationList() → {Promise.<any>}

Get group application and invitation application list

Example
let promise = TUIGroupService.getGroupApplicationList();
promise.then(function(chatResponse) {
  const { applicationList } = chatResponse.data;
  applicationList.forEach((item) => {
    // item.applicant - Applicant's userID
    // item.applicantNick - Applicant's nickname
    // item.groupID - Group ID
    // item.groupName - Group name
    // item.applicationType - Application type: 0 join group application, 2 invitation application
    // item.userID - When applicationType = 2, this is the invited user's userID
    // Business side can call handleGroupApplication to accept or reject group application
    TUIGroupService.handleGroupApplication({
      handleAction: 'Agree',
      application: {...item},
    });
  });
}).catch(function(imError) {
  // Business side can catch exceptions through promise.catch for error handling
});
Returns:
Type
Promise.<any>

handleGroupApplication(options) → {Promise.<any>}

Handle group application and invitation application

Examples
// Handle join group application through pending list
let promise = TUIGroupService.getGroupApplicationList();
promise.then(function(chatResponse) {
  const { applicationList } = chatResponse.data;
  applicationList.forEach((item) => {
    if (item.applicationType === 0) {
      TUIGroupService.handleGroupApplication({
        handleAction: 'Agree',
        application: {...item},
      });
    }
  });
}).catch(function(imError) {
  // Business side can catch exceptions through promise.catch for error handling
});
// Handle invitation application through pending list
let promise = TUIGroupService.getGroupApplicationList();
promise.then(function(chatResponse) {
  const { applicationList } = chatResponse.data;
  applicationList.forEach((item) => {
    if (item.applicationType === 2) {
      TUIGroupService.handleGroupApplication({
        handleAction: 'Agree',
        application: {...item},
      });
    }
  });
}).catch(function(imError) {
  // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options handleGroupApplicationParams

Parameters for handling group application

Returns:
Type
Promise.<any>

getGroupOnlineMemberCount(groupID) → {Promise.<any>}

Get group online member count

  • Note: Only supports getting online member count for live streaming groups
Example
let promise = TUIGroupService.getGroupOnlineMemberCount('group1');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupID string

Group ID

Returns:
Type
Promise.<any>

changeGroupOwner(options) → {Promise.<any>}

Transfer group ownership

Example
let promise = TUIGroupService.changeGroupOwner({
  groupID: 'group1',
  newOwnerID: 'user2'
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options ChangGroupOwnerParams

Group profile information

Returns:
Type
Promise.<any>

initGroupAttributes(groupAttributes) → {Promise.<any>}

Initialize group attributes

Example
let promise = TUIGroupService.initGroupAttributes({
  groupID: 'group1',
  groupAttributes: { key1: 'value1', key2: 'value2' }
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupAttributes GroupAttrParams

Group attribute information

Returns:
Type
Promise.<any>

setGroupAttributes(groupAttributes) → {Promise.<any>}

Set group attributes

Example
let promise = TUIGroupService.setGroupAttributes({
  groupID: 'group1',
  groupAttributes: { key1: 'value1', key2: 'value2' }
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
groupAttributes GroupAttrParams

Group attribute information

Returns:
Type
Promise.<any>

deleteGroupAttributes(options) → {Promise.<any>}

Delete group attributes

Example
let promise = TUIGroupService.deleteGroupAttributes({
  groupID: 'group1',
  keyList: ['key1', 'key2']
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options KeyListParams

Group attribute parameters

Returns:
Type
Promise.<any>

getGroupAttributes(options) → {Promise.<any>}

Get group attributes

Example
let promise = TUIGroupService.getGroupAttributes({
  groupID: 'group1',
  keyList: ['key1', 'key2']
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options KeyListParams

Group attribute parameters

Returns:
Type
Promise.<any>

setGroupCounters(counters) → {Promise.<any>}

Set counter

Example
let promise = TUIGroupService.setGroupCounters({
  groupID: 'group1',
  counters: { key1: 1, key2: 2 }
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
counters SetCountersParams

Counter information

Returns:
Type
Promise.<any>

increaseGroupCounter(options) → {Promise.<any>}

Increase counter

Example
let promise = TUIGroupService.increaseGroupCounter({
  groupID: 'group1',
  key: 'key1',
  value: 1,
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options CountersParams

Counter information

Returns:
Type
Promise.<any>

decreaseGroupCounter(options) → {Promise.<any>}

Decrease counter

Example
let promise = TUIGroupService.decreaseGroupCounter({
  groupID: 'group1',
  key: 'key1',
  value: 2,
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options CountersParams

Counter information

Returns:
Type
Promise.<any>

getGroupCounters(options) → {Promise.<any>}

Get counter

Example
let promise = TUIGroupService.getGroupCounters({
  groupID: 'group1',
  keyList: ['key1', 'key2']
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options KeyListParams

Counter parameters

Returns:
Type
Promise.<any>

getGroupMemberList(options) → {Promise.<any>}

Get group member list

Example
let promise = TUIGroupService.getGroupMemberList({
  groupID: 'group1',
  count: 15,
  offset: 0
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options GetMemberListParams

Parameter options

Returns:
Type
Promise.<any>

getGroupMemberProfile(options) → {Promise.<any>}

Get group member profile

Example
let promise = TUIGroupService.getGroupMemberProfile({
  groupID: 'group1',
  userIDList: ['user1', 'user2'], // Note: Even if only getting one member's profile, array type is required, e.g.: userIDList: ['user1']
  memberCustomFieldFilter: ['group_member_custom'], // Filter group member custom fields: group_member_custom
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options GetMemberProfileParams

Parameter options

Returns:
Type
Promise.<any>

addGroupMember(options) → {Promise.<any>}

Invite group members

Example
let promise = TUIGroupService.addGroupMember({
  groupID: 'group1',
  userIDList: ['user1','user2','user3']
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options AddMemberParams

Parameter options

Returns:
Type
Promise.<any>

deleteGroupMember(options) → {Promise.<any>}

Delete group members, group owner can remove group members.

  • Note 1: Enterprise package supports deleting live streaming group members. You can use this interface to achieve the effect of "banning group members" in live streaming groups.
  • Note 2: Kick duration field is only supported for live streaming groups (AVChatRoom).
  • Note 3: After a member is removed from a live streaming group, if they want to rejoin within the "kick duration", APP admin needs to call restapi to unban. After the "kick duration", users can actively join the live streaming group again.
Example
let promise = TUIGroupService.deleteGroupMember({
  groupID: 'group1',
  userIDList: ['user1'],
  reason: 'You violated the rules, I will kick you!',
  duration: 60
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options DeleteMemberParams

Parameter options

Returns:
Type
Promise.<any>

setGroupMemberMuteTime(options) → {Promise.<any>}

Set group member mute

Example
let promise = TUIGroupService.setGroupMemberMuteTime({
  groupID: 'group1',
  userID: 'user1',
  muteTime: 600 // Mute for 10 minutes; set to 0 to cancel mute
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options SetMemberMuteParams

Parameter options

Returns:
Type
Promise.<any>

setGroupMemberRole(options) → {Promise.<any>}

Set group member role

Example
let promise = TUIGroupService.setGroupMemberRole({
  groupID: 'group1',
  userID: 'user1',
  role: TUIChatEngine.TYPES.GRP_MBR_ROLE_ADMIN
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options SetMemberRoleParams

Parameter options

Returns:
Type
Promise.<any>

setGroupMemberNameCard(options) → {Promise.<any>}

Set group member name card

  • Note 1: Group owner can set name cards for all group members.
  • Note 2: Group admin can set their own and other ordinary members' name cards.
  • Note 3: Ordinary members can only set their own name cards.
Example
let promise = TUIGroupService.setGroupMemberNameCard({
  groupID: 'group1',
  userID: 'user1',
  nameCard: 'User Name Card'
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options SetMemberNameCardParams

Parameter options

Returns:
Type
Promise.<any>

setGroupMemberCustomField(options) → {Promise.<any>}

Set group member custom fields

Example
let promise = TUIGroupService.setGroupMemberCustomField({
  groupID: 'group1',
  memberCustomField: [{key: 'group_member_test', value: 'test'}]
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options SetMemberCustomFiledParams

Parameter options

Returns:
Type
Promise.<any>

markGroupMemberList(options) → {Promise.<any>}

Mark group members

  • Note 1: Only supported for live streaming groups.
  • Note 2: Only group owner has permission to mark other members in the group.
  • Note 3: Enterprise package is required to use this interface.
Example
let promise = TUIGroupService.markGroupMemberList({
  groupID: 'group1',
  userIDList: ['user1', 'user2'],
  markType: 1000,
  enableMark: true,
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options MarkMemberParams

Parameter options

Returns:
Type
Promise.<any>