December 1, 2020
The channel invitations feature and its accompanying options allow users or your backend to control the membership of private and public group chats, and allows users to inquire about their own channel membership. This blog post dives deep into channel invitations and all of the available options and events, and is broken down into four sections: general information about channel invitations, channel creation, private group channel invitations, and manual accept/decline invitations.
Channel invitations: general information
You can implement channel invitations either through a Sendbird Chat SDK or through the Platform API. This guide explores both options.
The channel invitations feature governs channel membership. Users become members of a private group channel in a couple ways:
At the time of channel creation, it is possible to pass in an array of up to 100 user IDs to become members of the channel After channel creation, it is also possible to invite up to 100 users per request
Users can inquire about their membership status in private and public group channels in a couple ways:
A user can retrieve a list of channels they were automatically joined to by invitation (default behavior) A user can retrieve a list of channels to which they’ve been invited by creating a channel list query instance Creating channels in Sendbird using an SDK or Platform API
Creating private group channels with either the Sendbird SDK or Platform API boils down to one main difference:
With channels created via the SDK, users have the freedom to chat and send channel invitations to whomever they like Using the Platform API, your backend controls which users chat to whom
Batches of up to 100 users can be invited to a private group channel at the point of creation or batches of up to 100 users can be invited at a later point, up to a maximum channel membership of 100 members. The maximum channel membership size can be increased upon request to Sendbird.
Creating channels using a Sendbird Chat SDK
By default, creating a channel via a Sendbird SDK gives users the freedom to start a chat with any other user so long as they know that user’s ID. Apps that are social in nature, build community, or depend on a user’s freedom to engage socially with other users will likely implement channel invitations through the SDK.
Note: The option to auto-accept invitations is “on” by default for Sendbird’s private group channels. For Sendbird’s public group channels no invitation is needed.
If auto-accept invitations is “on,” then the created channel will appear in the invited user’s channel list by default (if there are no messages, the invited user will need to add the filter to include empty channels). The invited user will also begin to receive notifications and messages from the created channel.
Creating a channel with the SDK automatically triggers the following events:
Event type Event Note Channel event handler (event delegate in iOS) onUserJoined() One event for each user in the member list onMessageReceived() If auto-generated admin messages are turned on (default: off) Webhooks group_channel:create
If auto-accept invitations is turned on (default: on) group_channel:create If auto-accept invitations is turned off Auto-generated admin messages (if: “on”) Message is sent.“The channel is created.“ The message contains channel detailsContinue reading