Subchannel

Subchannels are the part of a channel. They are separate topics or chat thread inside a channel. Messages can be sent & received in subchannel. By default, a channel itself would also generate a main subchannel once it's created. You can create, update, delete & query subchannels inside a channel. For the sturcture and relationship of channels and subchannels, please visit Channel and Subchannel Structure.

Limitations:

  • Sub-channel creation is supported for Conversation and Community channel types.

  • Users can create up to 300 sub-channels per channel.

Create Subchannel

In the concept of channels and subchannels, a channel is a primary container that can hold multiple subchannels. When you create a subchannel, it will serve as a thread where users can send messages and participate in discussions related to a specific thread. The subchannel creation function requires two parameters: channelId and displayName.

  • channelId: specifies the unique identifier of the parent channel where the subchannel will be created. This allows the SDK to link the subchannel to the correct parent channel, and organize it within the correct hierarchy.

  • displayName: Specifies the public name or label of the subchannel that will be visible to users.

Update Subchannel

When you update a subchannel's properties, the changes will be reflected for all users who are members of that subchannel. Please note that the updateSubChannel function only updates the properties of the subchannel itself, and does not affect any messages or other content that has been sent within the subchannel.

The function requires two parameters: subchannelId and displayName.

  • subhannelId: This is the unique identifier of the subchannel that you'd like to update.

  • displayName: This is the updated public name or label of the subchannel that will be visible to users.

Delete Subchannel

The subchannelId parameter specifies the ID of the subchannel that you'd like to delete. The hardDelete parameter is a boolean value that determines whether to perform a hard delete or a soft delete.

A soft delete will mark the subchannel as deleted but keep its data in the system. A hard delete will immediately and permanently delete the subchannel and all its data from the system.

Get Subchannel

To get a subchannel, you can use the getSubchannel method provided by the SubchannelRepository. This method accepts a subchannelId parameter and returns a Live Object of the AmitySubchannel class.

The AmitySubchannel class represents a subchannel in a channel. It contains information about the subchannel, such as its ID, display name, avatar, creation time, and more.

By using a Live Object combines with #real-time-events, you can observe any changes made to the subchannel in real-time. This is particularly useful in cases where multiple users may be interacting with the same subchannel and you need to keep the UI up-to-date with the latest data.

Query Subchannels

The getSubChannels function allows you to retrieve a list of subchannels within a specific channel. It accepts the channelId parameter to specify which channel to retrieve subchannels from.

The function returns a Live Collection, which allows you to observe changes to the collection in real-time.

Last updated