List all channels
GetChannels() returns a paginated list of all existing channels.
By default, this method returns all custom channel metadata without the need to explicitly define that during the call.
Requires App Context
To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.
If you have Access Manager enabled in your app, uncheck the Disallow Get All Channel Metadata option in the App Context configuration in the Admin Portal – this way you can get metadata of all channels without the need to define that in the permissions schema included in the authentication token.
To get a list of all channels a user is a member of, use the GetMemberships() method.
Method signature
This method takes the following parameters:
1chat.GetChannels(
2 string filter = "",
3 string sort = "",
4 int limit = 0,
5 PNPageObject page = null
6)
Input
| Parameter | Description |
|---|---|
filterType: stringDefault: empty string | Expression used to filter the results. Returns only these memberships whose properties satisfy the given expression. The filter language is defined here. |
sortType: stringDefault: empty string | Key-value pair of a property to sort by, and a sort direction. 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"}. By default, the items are sorted by the last updated date. |
limitType: intDefault: 0 | Number of objects to return in response. |
pageType: PNPageObjectDefault: null | Object used for pagination to define which previous or next result page you want to fetch. |
Output
| Type | Description |
|---|---|
Task<ChannelsResponseWrapper> | An awaitable Task with the object containing the filtered, sorted, and paginated list of channels. |
Sample code
Fetch all existing channel IDs.
1
Other examples
Pagination
Get the number of 25 channels and then specify that you want to fetch the results from the next page using a string previously returned from the PubNub server.
1