Advanced Member Discovery: The query member feature enables comprehensive member search and retrieval within chat channels. With support for filtering by membership status, roles, deletion status, and flexible sorting options, you can create seamless member management experiences.

Query Capabilities

Member querying provides flexible search and filtering options to help users find and manage channel participants effectively.

Advanced Filtering

Multiple filter criteria
  • Membership status filtering (active, muted, banned)
  • Role-based member filtering
  • Include/exclude deleted users
  • Flexible sorting options

Paginated Results

Efficient data loading
  • Pagination support for large member lists
  • Real-time updates with Live Collections
  • Search functionality with keyword matching
  • Customizable page sizes and limits

Implementation Guide

Essential member retrieval functionalityQuery members within a chat channel with flexible filtering and sorting options. This enables comprehensive member discovery and management within your chat application.

Required Parameters

ParameterTypeDescription
channelIdStringUnique identifier of the channel to query members from

Optional Parameters

ParameterTypeDefaultDescription
filterFilterEnumALLFilter members by membership status (ALL, MEMBER, MUTED, BANNED)
rolesArray<String>[]Filter members by specific roles assigned in the channel
includeDeletedBooleanfalseInclude members whose user accounts have been deleted
sortBySortEnumLAST_CREATEDSort order for member results (FIRST_CREATED, LAST_CREATED)

Code Examples

var token: AmityNotificationToken?

func queryMemberExample() {
  let membershipParticipation = AmityChannelParticipation(client: client, andChannel: "channel1")
    token = membershipParticipation
                .getMembers(filter: .all, sortBy: .firstCreated, roles: roles)
                .observe { collection, change, error in
        // ...
    }
}
Member Count Calculation: Channel member count value is based on all members in the channel including the members whose user has been deleted.

API Reference

Filter Options

Membership status filtering
  • ALL: Members with any membership status
  • MEMBER: Only active members
  • MUTED: Only muted members
  • BANNED: Only banned members

Sort Options

Result ordering
  • FIRST_CREATED: Oldest members first
  • LAST_CREATED: Newest members first

Membership Status Filters

FilterDescriptionUse Case
ALLMembers with any membership statusGeneral member lists, comprehensive views
MEMBEROnly active membersUser-facing member lists, active participant views
MUTEDOnly muted membersModeration interfaces, review muted users
BANNEDOnly banned membersAdministrative tools, ban management

Role-Based Filtering

ParameterTypeDescription
rolesArray<String>Filter members by specific roles (e.g., “moderator”, “admin”)

Data Inclusion Options

ParameterTypeDescription
includeDeletedBooleanWhether to include members whose user accounts have been deleted

Sorting Options

Sort OptionDescriptionBehavior
FIRST_CREATEDSort by membership creation date ascendingShows oldest members first
LAST_CREATEDSort by membership creation date descendingShows newest members first
Membership Creation Date: The membership creation date refers to when the user joined the channel, not when their user account was created.

Best Practices

Implementation Strategy: Start with basic member queries using default parameters, then progressively add filtering, search, and role-based access as your application grows. Use specific filters and pagination to optimize performance for channels with large member counts.