List all users
Get a paginated list of all users and their details using the getUsers() method.
By default, this method returns all custom user metadata without the need to define that during the call explicitly.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
This method takes the following parameters:
1chat.getUsers(
2 filter: String? = nil,
3 sort: [PubNub.ObjectSortField] = [],
4 limit: Int?,
5 page: PubNubHashedPage? = nil
6) async throws -> (users: [UserImpl], page: PubNubHashedPage?)
Input
| Parameter | Description |
|---|---|
filterType: StringDefault: n/a | Expression used to filter the results. Returns only these users whose properties satisfy the given expression are returned. The filtering language is defined here. |
sortType: [PubNub.ObjectSortField]Default: [] | A collection to specify the sort order. Available options are id, name, and updated. Use asc or desc to specify the sorting direction, or specify null to take the default sorting direction (ascending). For example: {name: "asc"}. Unless specified otherwise, the items are sorted by the last updated date. Defaults to an empty list. |
limitType: IntDefault: 100 | Number of objects to return in response. The default (and maximum) value is 100. |
pageType: PubNubHashedPageDefault: n/a | Object used for pagination to define which previous or next result page you want to fetch. |
Output
| Parameter | Description |
|---|---|
[UserImpl] | Object containing a set of users with pagination information (next, prev, total). |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Fetch all existing user IDs.
1
Other examples
Pagination
Get the total number of 25 users and then specify that you want to fetch the results from the next page using a page that was previously returned from the PubNub server.
1
Archived users
Get all archived users. This request will return all users removed with the soft option set to true, whose data is still stored in the App Context storage.
1