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

Open channel: Advanced

Copy link

This page explains the advanced features for open channels.


Send an admin message

Copy link

If you are using the Custom Plan, you can send an admin message to an open channel using Sendbird Dashboard or Chat Platform API. To send the admin message through your dashboard, on the Chat > Open channels, select an open channel, find a 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.

Note: For clients using the Free Plan, a suggesting message to upgrade to the Custom Plan will be returned when attempting to send an admin message using the Chat API.


Add a channel cover image

Copy link

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

OpenChannel.CreateChannel(NAME, COVER_IMAGE_OR_URL, DATA, (OpenChannel openChannel, 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 the UpdateChannel() method.


Categorize channels by custom type

Copy link

When creating an open channel, you can additionally specify a custom channel type to subclassify open channels. This custom type takes on the form of a String, and can be useful in searching or filtering open 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.

OpenChannel.CreateChannel(NAME, COVER_IMAGE_OR_URL, DATA, CUSTOM_TYPE, (OpenChannel openChannel, 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.

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

    ...
});

The CustomType property contains the message's custom type.


Search channels by name or URL

Copy link

You search for specific channels by adding a keyword to your OpenChannelListQuery instance. There are two types of keywords: a Name and a URL. The code below shows the query instance which returns the list of open channels that partially match the specified Name keyword in their names.

OpenChannelListQuery mListQuery = OpenChannel.CreateOpenChannelListQuery();
mListQuery.NameKeyword = "Sendbird";

mListQuery.Next((List<OpenChannel> channels, SendBirdException e) =>
{
    if (e != null)
    {
        // Handle error.
    }

    // Through "channels" parameter of the callback function, which Sendbird server has passed a result list to,
    // a list of channels that have 'Sendbird' in their names is returned.
    ...
});

The following shows the query instance which returns a list of open channels that partially match the specified URL keyword in the URLs of the channels.

OpenChannelListQuery mListQuery = OpenChannel.CreateOpenChannelListQuery();
mListQuery.UrlKeyword = "seminar";

mListQuery.Next((List<OpenChannel> channels, SendBirdException e) =>
{
    if (e != null)
    {
        // Handle error.
    }

    // Through "channels" parameter of the callback function, which Sendbird server has passed a result list to,
    // a list of open channels that have 'seminar' in their URLs is returned.
    ...
});

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");

openChannel.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);

Note: Message auto-translation is one of Sendbird's paid features. Contact our sales team for more information.