Chat SDKs Unity v3
Chat SDKs Unity
Chat SDKs
Unity
Version 3
Sendbird Chat SDK v3 for Unity is no longer supported as a new version is released. Check out our latest Chat SDK v4

Group channel: Advanced

Copy link

This page explains the advanced features for group channels.


Send typing indicators to other members

Copy link

If the StartTyping() and EndTyping() methods are called when a user is typing a text message, Sendbird server notifies of the event to the client apps of all channel members through the TypingStatusUpdate() of the registered channel event handler.

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

// To listen to an update from all the other channel members' client apps, implement the OnTypingStatusUpdated() with things to do when notified.
SendBirdClient.ChannelHandler ch = new SendBirdClient.ChannelHandler();
ch.OnTypingStatusUpdated = (GroupChannel groupChannel) =>
{
    if (currentGroupChannel.Url.Equals(groupChannel.Url))
    {
        List<User> members = groupChannel.TypingMembers;
        // Refresh typing status of members within channel.
    }
};

SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

Retrieve number of members who have not read a message

Copy link

If the MarkAsRead() method is called when a member reads messages, Sendbird server notifies of the event to the client apps of all channel members through the ReadReceiptUpdated() of the registered channel handler. Using this, you can make the channel up-to-date.

groupChannel.MarkAsRead();
...

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 the message.
            }
            else
            {
                // Some members haven't read the message.
            }
        }
    }
};

SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);

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

int unreadCount = groupChannel.GetReadReceipt(message);

Send an admin message

Copy link

You can send admin messages to a group channel using Sendbird Dashboard or Chat Platform API. To send an admin message through your dashboard, go to the Chat > Group channels, select a group channel, find the message box below, click the Admin message tab, and then write your message in the box. An admin message is limited to 1,000 characters.

Unlike other types of messages, a push notification for an admin message is not available by default. If you want further assistance on this, please contact our sales team.


Add a channel cover image

Copy link

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, (GroupChannel groupChannel, SendBirdException e) =>
{
    if (e != null)
    {
        // Handle error.
    }

    ...
});

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


Categorize channels by custom type

Copy link

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

The Data and CustomType properties of a channel object allow you to append information to your channels. While both properties can be used flexibly, common examples for the CustomType include categorizing channels into School or Work.

GroupChannel.CreateChannel(NAME, COVER_IMAGE_OR_URL, DATA, CUSTOM_TYPE, (GroupChannel groupChannel, SendBirdException e) =>
{
    if (e != null)
    {
        // Handle error.
    }

    ...
});

The CustomType property contains the channel's custom type.


Categorize messages by custom type

Copy link

When sending a message, you can additionally specify a custom message type to subclassify messages. This custom type takes on the form of a String, and can be useful in searching or filtering messages.

The Data and CustomType properties of a message object allow you to append information to your messages. While both properties can be used flexibly, common examples for the CustomType include categorizing message groups into Notes or Contacts.

To embed a custom type into your message, pass a String value as an argument to the parameter in the SendUserMessage() or SendFileMessage() method.

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

    ...
});

The CustomType property contains the message's custom type.


Message auto-translation

Copy link

It is possible for text messages to be sent in different languages through the Sendbird's auto-translation feature. When sending a text message, pass in a List of language codes to the SendUserMessage() to request translated messages in the corresponding languages.

Note: Message auto-translation is powered by Google Cloud Translation API recognition engine. Find language codes supported by the engine in the Miscellaneous page or visit the Language Support page in Google Cloud Translation.

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

groupChannel.SendUserMessage(MESSAGE, DATA, CUSTOM_TYPE, targetLangs, (UserMessage userMessage, SendBirdException e) =>
{
    if (e != null)
    {
        // Handle error.
    }

    ...
});

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) =>
{
    string EsTranslatedMessage = ((UserMessage)baseMessage).Translations["es"];
    string koTranslatedMessage = ((UserMessage)baseMessage).Translations["ko"];
    ...

    // Display translations in UI.
};

SendBirdClient.AddChannelHandler(UNIQUE_HANDLER_ID, ch);