Retrieving community subchannels
Use the client SDK to retrieve subchannels within a community channel.
Get joined subchannels
Call getSubChannels() on a CommunityChannel instance to retrieve the list of subchannels the current user has joined.
tip
This API only returns subchannels the current user belongs to. For a complete list of all subchannels (including those the user has not joined), maintain the list on your app server and serve it to the client.
- Kotlin
- Java
kotlin
val communityChannel = CommunityChannel("communityId")
communityChannel.getSubChannels { subChannels, error ->
if (error == null && subChannels != null) {
for (subChannel in subChannels) {
println("Subchannel ID: ${subChannel.subChannelId}")
println("Subchannel Type: ${subChannel.channelType}")
}
} else {
// Failed: ${error?.message}
}
}
Java
CommunityChannel communityChannel = new CommunityChannel("communityId");
communityChannel.getSubChannels((subChannels, error) -> {
if (error == null && subChannels != null) {
for (CommunitySubChannel subChannel : subChannels) {
String subChannelId = subChannel.getSubChannelId();
}
} else {
// Failed
}
});
CommunitySubChannel properties
| Property | Type | Description |
|---|---|---|
subChannelId | String | Subchannel ID |
channelType | Int | Subchannel type identifier |
Creating and deleting subchannels
Creating and deleting subchannels must be done via the Server API.
| Operation | Server API |
|---|---|
| Create a subchannel | Create Subchannel |
| Delete a subchannel | Delete Subchannel |
After creating or deleting a subchannel on your server, notify clients to refresh their subchannel lists.