For AI agents: this page in Markdown: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/list.md. Documentation index: https://www.pubnub.com/llms-full.txt.
List all channels
Get a paginated list of all channels with GetChannels(). Custom channel metadata is included by default.
Requires App Context
Enable App Context for your keyset in the Admin Portal.
With Access Manager enabled, uncheck Disallow Get All Channel Metadata in the App Context configuration to retrieve all channel metadata without defining permissions in the authentication token.
To list channels a user belongs to, use GetMemberships() instead.
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
filter#- Expression used to filter the results. Returns only these memberships whose properties satisfy the given expression. The filter language is defined here.
sort#- Key-value pair of a property to sort by, and a sort direction. Available options are
id,name, andupdated. Useascordescto specify the sorting direction, or specifynullto take the default sorting direction (ascending). For example:{name: "asc"}. By default, the items are sorted by the last updated date. limit#- Number of objects to return in response.
page#- 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.
1using System.Threading.Tasks;
2using PubnubApi;
3using PubnubChatApi;
4using UnityEngine;
5
6// Configuration
7PubnubChatConfig chatConfig = new PubnubChatConfig();
8
9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
10{
11 SubscribeKey = "demo",
12 PublishKey = "demo",
13 Secure = true
14};
15
show all 35 linesOther 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.
1using System.Threading.Tasks;
2using PubnubApi;
3using PubnubChatApi;
4using UnityEngine;
5
6// Configuration
7PubnubChatConfig chatConfig = new PubnubChatConfig();
8
9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
10{
11 SubscribeKey = "demo",
12 PublishKey = "demo",
13 Secure = true
14};
15
show all 52 lines