Options
All
  • Public
  • Public/Protected
  • All
Menu

Group contains APIs for group-related operations.

Index

Functions

  • Accepts a group invitation. If a group member invites a user to join the group, the invitee can call this method to accept the invitation. The inviter will receive "operation: 'acceptInvite'" in the callback of onGroupEvent. The new group member will receive "operation: 'memberPresence'" in the callback of onGroupEvent.

    connection.acceptGroupInvite({invitee: 'myUserId', groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<Common.CommonRequestResult>>

  • Accepts a group request. Only the group owner or admin can call this method. The user who joins the group will receive "operation: 'acceptRequest'" in the callback of onGroupEvent.

    connection.acceptGroupJoinRequest({applicant: 'user1', groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<Common.CommonRequestResult>>

  • Adds members to the group allowlist. Members on the allowlist can still post messages even if they are muted in the group. Only the group admin or above can call this method. Members added to the allowlist will receive "operation: 'addUserToAllowlist'" in the callback of onGroupEvent.

    connection.addUsersToGroupAllowlist({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult[]>>

  • Adds a member to the group blocklist. Only the group owner or admin can call this method. The member added to the blocklist will receive "operation: 'removeMember'" in the callback of onGroupEvent.

    connection.blockGroupMember({groupId: 'groupId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult>>

  • Adds members to the group blocklist in bulk. Only the group admin can call this method. Members added to the blocklist will receive "operation: 'removeMember'" in the callback of onGroupEvent.

    connection.blockGroupMembers({usernames: ['user1', 'user2'], groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult[]>>

  • createGroup(this: Connection, params: { data: { allowinvites: boolean; approval: boolean; desc: string; ext?: string; groupname: string; inviteNeedConfirm: boolean; maxusers: number; members: string[]; public: boolean }; error?: any; success?: any }): Promise<AsyncResult<CreateGroupResult>>
  • Creates a group instance.

    connection.createGroup({
    data: {
    groupname: 'groupname',
    desc: 'this is my group',
    members: ['user1', 'user2'],
    public: true,
    approval: false,
    allowinvites: true,
    inviteNeedConfirm: false,
    ext: {info: 'group info'}
    }
    })

    Parameters

    • this: Connection
    • params: { data: { allowinvites: boolean; approval: boolean; desc: string; ext?: string; groupname: string; inviteNeedConfirm: boolean; maxusers: number; members: string[]; public: boolean }; error?: any; success?: any }
      • data: { allowinvites: boolean; approval: boolean; desc: string; ext?: string; groupname: string; inviteNeedConfirm: boolean; maxusers: number; members: string[]; public: boolean }

        The group information.

        • allowinvites: boolean

          Whether to allow group members to invite others to the group. true: Allow; false: Do not allow.

        • approval: boolean

          Whether a user requires the approval from the group admin to join the group. -true: Yes; -false: No.

        • desc: string

          The description of the group.

        • Optional ext?: string

          Group detail extensions which can be in the JSON format to contain more group information.

        • groupname: string

          The group name.

        • inviteNeedConfirm: boolean

          Whether the invitee needs to accept the invitation before joining the group.

          • true: The invitee's consent is required. The default value is true.
          • false: The invitee will be directly added to the group without confirmation.
        • maxusers: number

          The group max users.

        • members: string[]

          The array of member IDs to add to the group. These users will be added directly into the group and receive "operation: 'directJoined'" in the callback of onGroupEvent.

        • public: boolean

          Whether it is a public group. -true: Yes; -false: No. Public group: the group that others can query by calling listgroups.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<CreateGroupResult>>

  • disableSendGroupMsg(this: Connection, params: { groupId: string; error?: any; success?: any }): Promise<AsyncResult<{ mute: true }>>
  • Mutes all members. Only the group admin or above can call this method. Group members will receive "operation: 'muteAllMembers'" in the callback of onGroupEvent.

     connection.disableSendGroupMsg({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<{ mute: true }>>

  • downloadGroupSharedFile(this: Connection, params: { fileId: string; groupId: string; secret?: string; onFileDownloadComplete?: any; onFileDownloadError?: any }): void
  • Down load group file.

    connection.downloadGroupSharedFile({groupId: 'groupId', fileId: 'fileId', onFileDownloadComplete: (data)=>{console.log(data)}})
    

    Parameters

    • this: Connection
    • params: { fileId: string; groupId: string; secret?: string; onFileDownloadComplete?: any; onFileDownloadError?: any }
      • fileId: string

        The shared file ID.

      • groupId: string

        The group ID.

      • Optional secret?: string

        The secret key required to download the file.

      • onFileDownloadComplete?:function
        • onFileDownloadComplete(data: Blob): void
        • Parameters

          • data: Blob

          Returns void

      • onFileDownloadError?:function

    Returns void

  • enableSendGroupMsg(this: Connection, params: { groupId: string; error?: any; success?: any }): Promise<AsyncResult<{ mute: false }>>
  • Unmute all members. Only the group admin or above can call this method. Group members will receive "operation: 'unmuteAllMembers'" in the callback of onGroupEvent.

    connection.enableSendGroupMsg({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<{ mute: false }>>

  • fetchGroupAnnouncement(this: Connection, params: { groupId: string; error?: any; success?: any }): Promise<AsyncResult<{ announcement: string }>>
  • Gets the group announcement.

    connection.fetchGroupAnnouncement({groupId: 'groupId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string; error?: any; success?: any }

    Returns Promise<AsyncResult<{ announcement: string }>>

  • Gets all admins in the group.

    connection.getGroupAdmin({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<UserId[]>>

  • Gets the group allowlist. Only the group admin or above can call this method.

    connection.getGroupAllowlist({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<UserId[]>>

  • Gets the group blocklist.

    connection.getGroupBlocklist({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<UserId[]>>

  • Gets all custom attributes of a group member.

    connection.getGroupMemberAttributes({groupId: 'groupId', userId: 'userId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string; userId: string }
      • groupId: string

        The group ID.

      • userId: string

        The user ID of the group member.

    Returns Promise<AsyncResult<MemberAttributes>>

  • Gets custom attributes of multiple group members by attribute key.

    connection.getGroupMembersAttributes({groupId: 'groupId', userIds: ['userId'], keys: ['avatar', 'nickname']})
    

    Parameters

    • this: Connection
    • params: { groupId: string; keys?: string[]; userIds: string[] }
      • groupId: string

        The group ID.

      • Optional keys?: string[]

        The array of keys of custom attributes to be retrieved. If you pass in an empty array or do not set this parameter, the SDK gets all custom attributes of these group members.

      • userIds: string[]

        The array of user IDs of group members whose custom attributes are retrieved.

    Returns Promise<AsyncResult<GetGroupMembersAttributesResult>>

  • Lists all the groups a user has joined.

    note

    If either needAffiliations or needAffiliations is set true, when you get data with pagination, the current page number (pageNum) starts from 0 and you can get a maximum of 20 groups (pageSize) on each page and the function return type is Promise<AsyncResult<GroupTypes.GroupInfo[]>

    If neither of the parameters is set, when you get data with pagination, the current page number (pageNum) starts from 1 and you can get a maximum of 500 groups (pageSize) on each page and and the function return type is Promise<AsyncResult<GroupTypes.BaseGroupInfo[]>

    connection.getJoinedGroups({
    pageNum: 1,
    pageSize: 500,
    needAffiliations: false,
    needRole: false
    })

    Parameters

    • this: Connection
    • params: { needAffiliations?: boolean; needRole?: boolean; pageNum: number; pageSize: number; error?: any; success?: any }
      • Optional needAffiliations?: boolean

        Whether the number of group members is required. true: Yes; (Default)false: No.

      • Optional needRole?: boolean

        Whether the role of the current user in the group is required. true: Yes; (Default)false: No.

      • pageNum: number

        If either needAffiliations or needAffiliations is set, when you get data with pagination, the current page number (pageNum) starts from 0.

        If neither of the parameters is set, when you get data with pagination, the current page number (pageNum) starts from 1.

      • pageSize: number

        If either needAffiliations or needAffiliations is set, when you get data with pagination, you can get a maximum of 20 groups (pageSize) on each page.

        If neither of the parameters is set, when you get data with pagination, you can get a maximum of 500 groups (pageSize) on each page.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<BaseGroupInfo[] | GroupInfo[]>>

  • Gets public groups with pagination.

    connection.getPublicGroups({limit: 20, cursor: null})
    

    Parameters

    • this: Connection
    • params: { cursor?: string; limit: number; error?: any; success?: any }
      • Optional cursor?: string

        The cursor that specifies where to start to get data. If there will be data on the next page, this method will return the value of this field to indicate the position to start to get data of the next page. If it is null, the data of the first page will be fetched.

      • limit: number

        The number of records per page.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<BaseGroupInfo[]>>

  • Invites users into a group. Creates a group instance "inviteNeedConfirm:true", the invited users will receive "operation: 'inviteToJoin'" in the callback of onGroupEvent. Creates a group instance "inviteNeedConfirm:false", the invited users will receive "operation: 'directJoined'" in the callback of onGroupEvent.

    connection.inviteUsersToGroup({groupId: 'groupId', users: ['user1', 'user2']})
    

    Parameters

    Returns Promise<AsyncResult<InviteUsersToGroupResult[]>>

  • isInGroupMutelist(this: Connection, params: { groupId: string }): Promise<boolean>
  • Check whether you are on the group mute list.

    connection.isInGroupMutelist({groupId: 'groupId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string }
      • groupId: string

        The group ID.

    Returns Promise<boolean>

  • leaveGroup(this: Connection, params: { groupId: string; error?: any; success?: any }): Promise<AsyncResult<{ result: true }>>
  • Leaves the group. Group members will receive "operation: 'memberAbsence'" in the callback of onGroupEvent.

    connection.leaveGroup({groupId: 'groupId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string; error?: any; success?: any }

    Returns Promise<AsyncResult<{ result: true }>>

  • listGroupMembers(this: Connection, params: { groupId: string; pageNum: number; pageSize: number; error?: any; success?: any }): Promise<AsyncResult<GroupMember[]>>
  • Lists all members of the group with pagination.

    connection.listGroupMembers({pageNum: 1, pageSize: 20, groupId: 'groupId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string; pageNum: number; pageSize: number; error?: any; success?: any }

    Returns Promise<AsyncResult<GroupMember[]>>

  • Modifies group information. Only the group admin can call this method.

    connection.modifyGroup({groupId: 'groupId', groupName: 'groupName', description:'description'})
    

    Parameters

    • this: Connection
    • params: { description?: string; ext?: string; groupId: string; groupName?: string; error?: any; success?: any }
      • Optional description?: string

        The group description.

      • Optional ext?: string

        Group detail extensions which can be in the JSON format to contain more group information.

      • groupId: string

        The Group ID.

      • Optional groupName?: string

        The group name.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<ModifyGroupResult>>

  • Mutes one or more group members. Only the group owner or admin can call this method. The muted member and other members will receive "operation:'muteMember'" in the callback of onGroupEvent.

    connection.muteGroupMember({username: 'user1' || ['user1', 'user2'], muteDuration: -1, groupId: 'groupId'})
    

    Parameters

    • this: Connection
    • params: { groupId: string; muteDuration: number; username: string | string[]; error?: any; success?: any }

    Returns Promise<AsyncResult<MuteGroupMemberResult[]>>

  • Removes a group admin. Only the group owner can call this method. The user whose admin permissions are revoked will receive "operation: 'removeAdmin'" in the callback of onGroupEvent.

    connection.removeGroupAdmin({groupId: 'groupId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<RemoveGroupAdminResult>>

  • Removes a member from the group allowlist. Only the group admin or above can call this method. The user that is removed from the group allowlist will receive "operation:'removeAllowlistMember'" in the callback of onGroupEvent.

    connection.removeGroupAllowlistMember({groupId: 'groupId', userName: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult>>

  • Removes a member from the group. Only the group owner or admin can call this method. The removed member will receive "operation: 'removeMember'" in the callback of onGroupEvent, and other group members will receive "operation: 'memberAbsence' in the callback of onGroupEvent.

    connection.removeGroupMember({groupId: 'groupId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<RemoveGroupMemberResult>>

  • Removes members from the group. Only the group owner or admin can call this method. The removed members will receive "operation: 'removeMember'" in the callback of onGroupEvent, and other group members will receive "operation: 'memberAbsence'" in the callback of onGroupEvent.

    connection.removeGroupMembers({groupId: 'groupId', users: ['user1', 'user2']})
    

    Parameters

    Returns Promise<AsyncResult<RemoveGroupMemberResult[]>>

  • Sets a group admin. Only the group owner can call this method. The user set as an admin will receive "operation: 'setAdmin'" in the callback of onGroupEvent.

    connection.setGroupAdmin({groupId: 'groupId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<SetGroupAdminResult>>

  • setGroupMemberAttributes(this: Connection, params: { groupId: string; memberAttributes: MemberAttributes; userId: string }): Promise<void>
  • Sets custom attributes of a group member. After custom attributes of a group member are set, other members in the group receive the operation: 'memberAttributesUpdate' in the onGroupEvent callback and the other devices of the group member receive the the operation: 'memberAttributesUpdate' in the onMultiDeviceEvent callback.

    connection.setGroupMemberAttributes({groupId: 'groupId', userId: 'userId', memberAttributes: {key: 'value'}})
    

    Parameters

    • this: Connection
    • params: { groupId: string; memberAttributes: MemberAttributes; userId: string }
      • groupId: string

        The group ID.

      • memberAttributes: MemberAttributes

        The custom attributes to set in key-value format. In a key-value pair, if the value is set to an empty string, the custom attribute will be deleted.

      • userId: string

        The user ID of the group member.

    Returns Promise<void>

  • Removes a member from the group blocklist. Only the group admin can call this method. Members who are removed from the blocklist will receive "operation: 'unblockMember'" in the callback of onGroupEvent.

    connection.unblockGroupMember({groupId: 'groupId'})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult>>

  • Removes members from the group blocklist in bulk. Only the group owner or admin can call this method. Members who are removed from the blocklist will receive "operation: 'unblockMember'" in the callback of onGroupEvent.

    connection.unblockGroupMembers({groupId: 'groupId', usernames: ['user1', 'user2']})
    

    Parameters

    Returns Promise<AsyncResult<GroupRequestResult[]>>

  • Unmutes one or more group members. Only the group owner or admin can call this method. The unmuted member and other members will receive "operation: 'unmuteMember'" in the callback of onGroupEvent.

    connection.unmuteGroupMember({groupId: 'groupId', username: 'user1' || ['user1', 'user2']})
    

    Parameters

    Returns Promise<AsyncResult<UnmuteGroupMemberResult[]>>

  • uploadGroupSharedFile(this: Connection, params: { file: object; groupId: string; onFileUploadCanceled?: any; onFileUploadComplete?: any; onFileUploadError?: any; onFileUploadProgress?: any }): void
  • Uploads shared files to the group.

    connection.uploadGroupSharedFile({groupId: 'groupId', file: 'file object', onFileUploadProgress: onFileUploadProgress, onFileUploadComplete: onFileUploadComplete,onFileUploadError:onFileUploadError,onFileUploadCanceled:onFileUploadCanceled})
    

    Parameters

    • this: Connection
    • params: { file: object; groupId: string; onFileUploadCanceled?: any; onFileUploadComplete?: any; onFileUploadError?: any; onFileUploadProgress?: any }
      • file: object

        The shared file object to upload.

      • groupId: string

        The group ID.

      • onFileUploadCanceled?:function
        • onFileUploadCanceled(data: any): void
        • The upload cancellation callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadComplete?:function
        • onFileUploadComplete(data: any): void
        • The upload completion callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadError?:function
        • onFileUploadError(data: any): void
        • The upload failure callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadProgress?:function
        • onFileUploadProgress(data: ProgressEvent<EventTarget>): void
        • The upload progress callback.

          Parameters

          • data: ProgressEvent<EventTarget>

          Returns void

    Returns void

Generated using TypeDoc