Channel Management
Channel Members
When a user joins a channel, they are able to observe and chat with other users in that channel. They are also automatically considered a member of that channel. The Chat SDK provides the ability to view which users are currently in the channel as well as invite other users to join the channel.
Channel Type | Discoverable by | Message sending privileges | Moderation access |
Community | All users and admins | Users and admins | All Moderation tools |
Live | Only members and admins | Users and admins | All Moderation tools |
Broadcast | All users and admins | Admins | Admin Moderation tools |
Conversation | Only members | Users | No Moderation tools |
Each channel is identified by a unique channelId
, which is any string that uniquely identifies the channel and is immutable through its lifetime. When creating channels, you can specify your own channelId
, or leave it to Amity's Chat SDK to automatically generate one for you.
There can be only one and one only channel with a given
channelId
. An error will be thrown when trying to generate two channels with the samechannelId
.
There are three ways of obtaining a channel:
create
join
get
createChannel
guarantees that the requested channel is a new channel, whereas joinChannel
will attempt to join an existing channel. If there is a requirement to create a new channel, use createChannel
then call joinChannel
. Lastly, calling getChannel
only gives you back the channel data, but it won't make you join the said channel.
Create Channel
TypeScriptSDK provides createChannel
method to create a new channel. It supports creating of 3 types of channels Community
, Live
and Conversation
. Each channel type has specific builder classes which helps you create that particular channel. Build your channel information first and then create the particular channel.
The above code creates a channel and notifies you through the callback.
3 channel types can be created through SDK i.e
Community
,Live
andConversation
. Creation ofPrivate
andStandard
type has been removed. Creation ofBroadcast
channel type is not supported through the SDK. But for query,channelCollection:
method supports all channel types includingBroadcast
,Private
andStandard
.
Join Channel
joinChannel
is an idempotent method. This means that it can be called multiple times throughout the lifecycle of the application, and you can expect this method to always return the same channel. Because of this, you can also use joinChannel
any time you need to fetch a channel, even if you know the user may already be in the channel.
Leave Channel
Get Channel
In cases where you'd like to fetch a channel's data without joining, the getChannel
method can be used:
Observe Channel
To display the channel, you may also use observeChannel
Channel Query
TypeScript SDK provides a way to query a list of channels using the queryChannels
method. It returns a list of all the matching channels available.
To further query liveChannels
using filter query parameters. Possible values are all
, member
, notMember
, and flagged
.
Channel Filtering
You can filter channels by various criteria such as membership
and displayName
.
Delete Channel
Metadata
Metadata is a general purpose data store that is automatically synchronized to all the channel members. It is meant as an elegant mechanism to store contextual information about a specific channel. The data can be any number of JSON key value pairs up to 100 kb.
Example use cases include:
Conversation title or cover photo
Global conversation settings
Metadata is implemented with last writer wins semantics: multiple mutations by independent users to the metadata object will result in a single stored value. No locking, merging, or other coordination is performed across multiple writes on the data.
To set metadata, call the following method:
The completion block will be triggered with the outcome of the request. The latest metadata of the channel is always exposed as part of the metadata
property on the channel model.
Display Name
Every channel contains an optional displayName
property. This property is mainly used to identify the channel in push notifications.
You can set a channel's displayName
with the following method:
Last updated