Group Channel: Advanced

This section explains the premium features of Group Channel. Some are available only to a paying user.


Getting a list of all channel members

You can obtain a list of members in a group channel by retrieving channel.Members.

List<User> members = groupChannel.Members;

Members are automatically updated when you are online. If you disconnect from SendBird and reconnect, Refresh() the channel to be updated with the latest information.

groupChannel.Refresh((SendBirdException e) => {
    if (e != null) {
        //Error.
        return;
    }
});

Getting members' online statuses

To stay updated on each member's connection status, call channel.Refresh() before accessing channel.Members. You can then check each of the users' connection statuses by accessing user.ConnectionStatus.

Note: If your app needs to keep track of users' connection statuses in real time, we recommend that you Refresh() your channel instance periodically, perhaps in intervals of one minute or more.

ConnectionStatus can return one of three values:

  • User.ConnectionStatus.NON_AVAILABLE: user's status information cannot be reached.
  • User.ConnectionStatus.OFFLINE: user is disconnected from SendBird.
  • User.ConnectionStatus.ONLINE: user is connected to SendBird.

Typing indicators

You can send typing events by invoking StartTyping() and EndTyping().

groupChannel.StartTyping();
groupChannel.EndTyping();

You can receive a TypingStatusUpdate event from a Channel Handler.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnTypingStatusUpdated = (GroupChannel groupChannel) => {
    if (currentGroupChannel.Url.Equals(groupChannel.Url)) {
        List<User> members = groupChannel.TypingMembers;
        // Refresh typing status.
    }
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Read receipts

A user can indicate that they have read messages in a channel by calling MarkAsRead().

groupChannel.MarkAsRead();

You can receive a ReadReceiptUpdate event from a Channel Handler.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnReadReceiptUpdated = (GroupChannel groupChannel) => {
    if (currentGroupChannel.Url.Equals(groupChannel.Url)) {
        foreach (BaseMessage msg in yourMessages) {
            int unreadCount = groupChannel.GetReadReceipt(msg);
            if (unreadCount <= 0) {
                // All members have read.
            } else {
                // Some members haven't read.
            }
        }
    }
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

GetReadReceipt(message) returns the number of members in the channel who have not read the message.

int unreadCount = groupChannel.GetReadReceipt(message);

Admin messages

You can send an admin message to users in a channel using the SendBird Dashboard or the Platform API. To send the admin message via the Dashboard, in the Group Channels panel, select a group channel, find a message box below, click the Admin Message tab, and write a message in the box. The admin message is limited to 1000 characters.

If you are currently developing under the Free Plan and therefore cannot use the Moderation Tools from the Dashboard, you must send the admin messages through the Platform API.


Channel cover images

When creating a channel, you can add a cover image by specifying an image URL or file.

GroupChannel.CreateChannel(NAME, COVER_IMAGE_OR_URL, DATA, (OpenChannel openChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

You can fetch the cover image URL using the CoverUrl property. You can also update a channel's cover image by calling UpdateChannel().


Custom channel types

When creating a channel, you can additionally specify a custom type to further subclassify your channels. This custom type takes on the form of a String, and can be handy in searching or filtering channels.

Note: DATA and CUSTOM_TYPE are both String fields that allow you to append information to your channels. The intended use case is for CUSTOM_TYPE to contain information that can subclassify the channel (for example, distinguishing "School" and "Work" channels). However, both these fields can be flexibly utilized.

GroupChannel.CreateChannel(NAME, COVER_IMAGE_OR_URL, DATA, CUSTOM_TYPE, (OpenChannel openChannel, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

The CustomType property contains the channel's custom type.


Custom message types

Likewise, you can specify a custom type for messages to categorize them into more specific groups. This custom type takes on the form of a String, and can be useful in searching or filtering messages.

Note: DATA and CUSTOM_TYPE are both String fields that allow you to append information to your messages. The intended use case is for CUSTOM_TYPE to contain information that can subclassify the message (for example, distinguishing "FILE_IMAGE" and "FILE_AUDIO" type messages). However, both these fields can be flexibly utilized.

To embed a custom type into a message, simply pass a String parameter to channel.SendUserMessage() or channel.SendFileMessage().

groupChannel.SendUserMessage(MESSAGE, DATA, CUSTOM_TYPE, (UserMessage userMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

The CustomType property contains the message's custom type.


Message auto-translation

This feature is not available under the Free plan. Contact our sales team if you want to implement this functionality.

SendBird makes it possible for messages to be sent in different languages through its auto-translation feature. Pass in a List of language codes to SendUserMessage() to request translated messages in the corresponding languages.

List<string> targetLangs = new List<string>();
targetLangs.Add("es");
targetLangs.Add("ko");

openChannel.SendUserMessage(MESSAGE, DATA, CUSTOM_TYPE, targetLangs, (UserMessage userMessage, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

You can obtain translations of a message through the Translations property. This contains a Dictionary containing the language codes and translations.

SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnMessageReceived = (BaseChannel baseChannel, BaseMessage baseMessage) => {
    // Received a chat message.
    // ((UserMessage)baseMessage).Translations["es"];
    // ((UserMessage)baseMessage).Translations["ko"];
};
SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Note: The message auto-translation supports 53 languages. For the language code table, see the Miscellaneous > Supported Languages.