Android
Open Channel

Open Channel

An open channel is basically a public chat and it can handle a large number of participants online. In this channel type, anyone can enter and participate in the chat without permission. A single open channel can accomodate up to 1,000, simultaneous users like Twitch-style public chat. This maximum number of an open channel's participants can increase per request.


Create a channel

An open channel is ideal for use cases that require a small and static number of channels. To create an open channel from the SendBird Dashboard, do the following:

  1. In your dashboard, go to the Application > Open channels panel, and then click Create channel at the top-right corner.
  2. In the dialog box that appears, specify the name, URL, cover image, and custom type of a channel (the channel URL is a unique identifier of a channel.)

You can also create a channel on demand or dynamically via the SDK or the Platform API.

Light Color Skin
Copy
OpenChannel.createChannel(new OpenChannel.OpenChannelCreateHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

When creating a channel, you can also append additional information like cover image and description by specifying several parameters.

Light Color Skin
Copy
OpenChannel.createChannel(NAME, COVER_IMAGE_OR_URL, DATA, OPERATORS, CUSTOM_TYPE, HANDLER);
ParameterTypeDescription

NAME

string

Specifies the channel topic, or the name of the channel.

COVER_IMAGE_OR_URL

object

Specifies the cover image URL of the channel, or uploads a file for the cover image.

DATA

string

Specifies additional data that you can store for the channel.

OPERATORS

list

Specifies a list of one or more users to register as operators to the channel. Operators can delete any messages, and also view all messages in the channel without any filtering or throttling.

CUSTOM_TYPE

string

Specifies the custom channel type which is used for channel grouping.

HANDLER

interface

Specifies the OpenChannelCreateHandler interface which contains the onResult() callback to receive the response from SendBird server for a channel creation request.

Using the getCoverUrl() and updateChannel() methods, you can get and update the cover image URL of a channel.


Enter a channel

A user must enter an open channel to receive messages. The user can enter up to 10 open channels at once, which are valid only within a current connection. So when a user is disconnected from SendBird server with the disconnect() and reconnected to the server with the connect(), you should make sure the user re-enters the open channels for them to continue receiving messages.

Note: When a user is reconnected by attempts of the SendBird instance from a temporary unstable connection, the user is automatically re-entered into the participating channels.

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }

        openChannel.enter(new OpenChannel.OpenChannelEnterHandler() {
            @Override
            public void onResult(SendBirdException e) {
                if (e != null) {    // Error.
                    return;
                }
            }
        });
    }
});

Exit a channel

If a user exits an open channel, the user can't receive any messages from that channel.

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }

        openChannel.exit(new OpenChannel.OpenChannelExitHandler() {
            @Override
            public void onResult(SendBirdException e) {
                if (e != null) {    // Error.
                    return;
                }
            }
        });
    }
});

Freeze and unfreeze a channel

An open channel can be freezed only with the SendBird Dashboard or Platform API as opposed to a group channel which operators of the channel can do that via the SDKs.

To freeze, go to your dashboard and do the following: on the Application > Open channels panel, select an open channel to freeze, and click the Freeze icon at the upper right corner. To unfreeze, click the icon again with the frozen channel selected.

Note: In a frozen channel, participants can't chat one another but the operators can send a message to the channel.


Delete a channel

Only the operators of an open channel can delete the channel (the following code works properly in the operators' client apps only). Otherwise, an error is returned through the OpenChannelDeleteHandler.

Light Color Skin
Copy
OpenChannel.delete(new OpenChannelDeleteHandler() {
    @Override
    public void onResult(SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

Retrieve a list of channels

You can retrive a list of OpenChannel objects using the next() method of an OpenChannelListQuery instance like the following.

Light Color Skin
Copy
OpenChannelListQuery channelListQuery = OpenChannel.createOpenChannelListQuery();
channelListQuery.next(new OpenChannelListQuery.OpenChannelListQueryResultHandler() {
    @Override
    public void onResult(List<OpenChannel> openChannels, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

Retrieve a channel by URL

Since a channel URL is a unique identifier of an open channel, you can use a URL when retrieving a channel object.

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }

    // TODO: Implement what is needed with the contents of the response in the openChannel parameter.
    }
});

Note: We recommend that you store a user's channel URLs to handle the lifecycle or state changes of your app, or any other unexpected situations. For example, when a user is disconnected from SendBird server due to switching to another app temporarily, you can provide a smooth restoration of the user's state using a stored URL to fetch the appropriate channel instance.


Send a message

In an entered channel, a user can send messages of the following types:

  • UserMessage: a text message sent by a user.
  • FileMessage: a binary file message sent by a user.

You can additionally specify a CUSTOM_TYPE to further subclassify a message. When you send a text message, you can additionally attach arbitrary strings via a data field. You can utilize this field to send structured data such as font sizes, font types, or custom JSON objects.

Message delivery failures due to the network issues return an exception. By implementing the onSent() within the context of the sendUserMessage() method, you can display messages that are successfully sent to a channel.

Light Color Skin
Copy
List<String> userIDsToMention = new ArrayList<>();
userIDsToMention.add("Jeff");
userIDsToMention.add("Julia");

List<String> metaArrayKeys = new ArrayList<>();
metaArrayKeys.add("linkTo");
metaArrayKeys.add("itemType");

List<String> translationTargetLanguages = new ArrayList<>();
translationTargetLanguages.add("fr");       // French
translationTargetLanguages.add("de");       // German

UserMessageParams params = new UserMessageParams()
        .setMessage(TEXT_MESSAGE)
        .setCustomType(CUSTOM_TYPE)
        .setData(DATA)
        .setMentionType(MentionType.USERS)      // Either USERS or CHANNEL
        .setMentionedUserIds(userIDsToMention)      // Or .setMentionedUsers(LIST_OF_USERS_TO_MENTION)
        .setMetaArrayKeys(metaArrayKeys)
        .setTranslationTargetLanguages(translationTargetLanguages)
        .setPushNotificationDeliveryOption(PushNotificationDeliveryOption.DEFAULT); // Either DEFAULT or SUPPRESS

openChannel.sendUserMessage(params, new BaseChannel.SendUserMessageHandler() {
    @Override
    public void onSent(UserMessage userMessage, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

A user can also send any binary file through the SDK. The two ways to send a binary file are provided: by sending the file itself, or by sending a URL.

Sending a raw file indicates that you upload it to SendBird server and it can be downloaded from the server when needed in client apps. As another option, you can choose to send a file hosted on your server by passing a URL that represents the location of the file as a parameter. In this case, your file isn't hosted on SendBird server, and can be downloaded only from your own server instead.

Note: If you upload a file directly, a size limit is imposed per file depending on your plan. You can see your limit in the dashboard and adjust the limit via our sales team. No file size limit is imposed if you send a file message with its URL since the file isn't uploaded to SendBird server.

Light Color Skin
Copy
// Sending a file message with a raw file
List<FileMessage.ThumbnailSize> thumbnailSizes = new ArrayList<>(); // Allowed number of thumbnail images: 3
thumbnailSizes.add(new ThumbnailSize(100,100));
thumbnailSizes.add(new ThumbnailSize(200,200));

List<String> userIDsToMention = new ArrayList<>();
userIDsToMention.add("Jeff");
userIDsToMention.add("Julia");

List<String> metaArrayKeys = new ArrayList<>();
metaArrayKeys.add("linkTo");
metaArrayKeys.add("itemType");

List<String> translationTargetLanguages = new ArrayList<>();
translationTargetLanguages.add("fr");       // French
translationTargetLanguages.add("de");       // German

FileMessageParams params = new FileMessageParams()
        .setFile(FILE)              // Or .setFileURL(FILE_URL). You can also send a file message with a file URL.
        .setFileName(FILE_NAME)
        .setFileSize(FILE_SIZE)
        .setMimeType(MIME_TYPE)
        .setThumbnailSizes(thumbnailSizes)
        .setCustomType(CUSTOM_TYPE)
        .setData(DATA)
        .setMentionedType(MentionType.USERS)        // Either USERS or CHANNEL
        .setMentionedUserIds(userIDsToMention)      // Or .setMentionedUsers(LIST_OF_USERS_TO_MENTION)
        .setMetaArrayKeys(metaArrayKeys)
        .setTranslationTargetLanguages(translationTargetLanguages)
        .setPushNotificationDeliveryOption(PushNotificationDeliveryOption.DEFAULT);     // Either DEFAULT or SUPPRESS

openChannel.sendFileMessage(params, new BaseChannel.SendFileMessageHandler() {
    @Override
    public void onSent(FileMessage fileMessage, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

Note: To send metadata along with a file, you can populate the DATA field.


Receive messages through a channel event handler

Messages sent from other participants can be received through the onMessageReceived() method of a channel event handler. A BaseMessage object for each received message is one of the following three message types.

  • UserMessage: a text message sent by a user.
  • FileMessage: a binary file message sent by a user.
  • AdminMessage: a text message sent by an admin through the Platform API.

The UNIQUE_HANDLER_ID is a unique identifier to register multiple concurrent handlers.

Light Color Skin
Copy
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() {
    @Override
    public void onMessageReceived(BaseChannel channel, BaseMessage message) {
        // TODO: Implement what is needed with the contents of the response in the the 'message' parameter.
        if (message instanceof UserMessage) {
            ... 
        } else if (message instanceof FileMessage) {
            ... 
        } else if (message instanceof AdminMessage) {
            ... 
        }
    }
});

Mention other participants in a message

When a participant wants to call the attention of other participants in an open channel where push notifications are not allowed by default, they can mention those participants in a message. To do so, you should:

  1. Specify a list of the user IDs to mention.
  2. Add the list to either UserMessageParams or FileMessageParams which may contain options for further action.
  3. Pass the params to either sendUserMessage() or sendFileMessage().
  4. Then only up to 10 participants mentioned in the message will be notified.
Light Color Skin
Copy
List<String> userIDsToMention = new ArrayList<>();
userIDsToMention.add("Harry");
userIDsToMention.add("Jay");
userIDsToMention.add("Jin");

UserMessageParams params = new UserMessageParams(MESSAGE)
    .setMentionedUserIds(userIDsToMention);

openChannel.sendUserMessage(params, new BaseChannel.SendUserMessageHandler() {
    @Override
    public void onSent(UserMessage userMessage, SendBirdException e) {
        if (e != null) {        // Error.
            return;
        }
    }
});

Load previous messages

Using the load() method of a PreviousMessageListQuery instance which returns a list of BaseMessage objects, you can retrieve a set number of previous messages in an open channel. With a returned list, you can display the past messages in your UI once they have loaded.

Light Color Skin
Copy
// There should only be one single instance per channel view.
PreviousMessageListQuery prevMessageListQuery = openChannel.createPreviousMessageListQuery();

...

// Retrieving previous messages.
prevMessageListQuery.load(LIMIT, REVERSE, new PreviousMessageListQuery.MessageListQueryResult() {
    @Override
    public void onResult(List<BaseMessage> messages, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});
ParameterTypeDescription

LIMIT

int

Specifies the number of results to return per call. Acceptable values are 1 to 100, inclusive. The recommended value for this parameter is 30.

REVERSE

boolean

Determines whether to sort the retrieved messages in the reversed order. If true, returns a list of messages which the latest comes at first and the earlist at last. the results are sorted in the reversed order. If false, returns a list of messages which the earlist comes at first and the latest at last.

A LIMIT parameter indicates how many messages should be included in a returned list. A PreviousMessageListQuery instance itself does pagination of a result set based on the value of the LIMIT parameter, and internally manages a token to retrieve the next page in the result set.

Each time the load() method is called, the instance retrieves a set number of messages in the next page and then updates the value of the token to complete the current call and prepare a next call.

If you create a new PreviousMessageListQuery instance and call the load() method, a set number of the most recent messages are retrieved because its token has nothing to do with the previously created instance. So we recommend that you create a single query instance and store it as a member variable for traversing through the entire message history.

Note: Before calling the load() method again, you must receive a success callback through the onResult() first.


Load messages by timestamp or message ID

You can retrieve a set number of messages sent previously before a specific timestamp in an open channel, using the getPreviousMessagesByTimestamp() method.

Light Color Skin
Copy
openChannel.getPreviousMessagesByTimestamp(TIMESTAMP, IS_INCLUSIVE, PREV_RESULT_SIZE, REVERSE, MESSAGE_TYPE, CUSTOM_TYPE, new BaseChannel.GetMessagesHandler() {
    @Override
    public void onResult(List<BaseMessage> list, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    
        // A list of messages sent before the specified timestamp is successfully retrieved.
    }
});
ParameterTypeDescription

TIMESTAMP

long

Specifies the timestamp to be the reference point of a retrieval, in Unix milliseconds.

IS_INCLUSIVE

boolean

Determines whether to include the messages sent exactly on the TIMESTAMP.

PREV_RESULT_SIZE

int

Specifies the number of messages to retrieve. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the earliest message.

REVERSE

boolean

Determines whether to sort the retrieved messages in the reversed order.

MESSAGE_TYPE

enum

Specifies the message type to filter the messages with the corresponding type. Acceptable values are MessageTypeFilter.ALL, MessageTypeFilter.USER, MessageTypeFilter.FILE, and MessageTypeFilter.ADMIN.

CUSTOM_TYPE

string

Specifies the custom message type to filter the messages with the corresponding custom type.

Note: To retrieve messages sent after a specified timestamp, use the getNextMessagesByTimestamp() in a similar fashion. Using the getPreviousAndNextMessagesByTimestamp(), you can retrieve previous and next messages on both sides of a specific timestamp.

You can also retrieve a set number of messages sent previously before a specific message ID in an open channel, using the getPreviousMessagesById() method.

Light Color Skin
Copy
openChannel.getPreviousMessagesById(MESSAGE_ID, IS_INCLUSIVE, PREV_RESULT_SIZE, REVERSE, MESSAGE_TYPE, CUSTOM_TYPE, new BaseChannel.GetMessagesHandler() {
    @Override
    public void onResult(List<BaseMessage> list, SendBirdException e) {
        if (e != null) {        // Error.
            return;
        }

        // A list of messages, the IDs of which are ahead of the specified message ID, is successfully retrieved.
    }
});
ParameterTypeDescription

MESSAGE_ID

long

Specifies the unique ID of the message to be the reference point of a retrieval.

IS_INCLUSIVE

boolean

Determines whether to include the messages sent exactly on the TIMESTAMP.

PREV_RESULT_SIZE

int

Specifies the number of messages to retrieve. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the earliest message.

REVERSE

boolean

Determines whether to sort the retrieved messages in the reversed order.

MESSAGE_TYPE

enum

Specifies the message type to filter the messages with the corresponding type. Acceptable values are MessageTypeFilter.ALL, MessageTypeFilter.USER, MessageTypeFilter.FILE, and MessageTypeFilter.ADMIN.

CUSTOM_TYPE

string

Specifies the custom message type to filter the messages with the corresponding custom type.

Note: To retrieve messages sent after a specific message ID, use the getNextMessagesById() in a similar fashion. By using the getPreviousAndNextMessagesById() method, you can also retrieve previous and next messages on both sides of a specific message ID.


Update a message

A user can update any of their own text and file messages sent. An error is returned if a user attempts to update another user's messages. In addition, channel operators can update any messages sent in the channel.

Light Color Skin
Copy
// For a text message
UserMessageParams params = new UserMessageParams()
        .setMessage(NEW_TEXT_MESSAGE)
        .setCustomType(NEW_CUSTOM_TYPE)
        .setData(NEW_DATA);

// The MESSAGE_ID below indicates the unique message ID of a UserMessage object to update.
openChannel.updateUserMessage(MESSAGE_ID, params, new BaseChannel.UpdateUserMessageHandler() {
    @Override
    public void onUpdated(UserMessage userMessage, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

...

// For a file message
FileMessageParams params = new FileMessageParams()
        .setFileURL(NEW_FILE_URL)       // The file in a message can't be updated.
        .setFileName(NEW_FILE_NAME)
        .setFileSize(NEW_FILE_SIZE)
        .setData(NEW_DATA);

// The MESSAGE_ID below indicates the unique message ID of a FileMessage object to update.
openChannel.updateFileMessage(MESSAGE_ID, params, new BaseChannel.UpdateFileMessageHandler() {
    @Override
    public void onUpdated(FileMessage fileMessage, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

The onMessageUpdated() method of a channel event handler will receive a callback from the server when a message is updated, and all participants of the channel will be notified, including who has updated their own message.

Light Color Skin
Copy
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() {
    ...

    @Override
    public void onMessageUpdated(BaseChannel channel, BaseMessage message) {
    
    }
    ...

});

Delete a message

A user can delete any messages sent by themselves. An error is returned if a user attempts to delete the messages of other participants. Also channel operators can delete any messages in the channel.

Light Color Skin
Copy
// The BASE_MESSAGE below indicates a BaseMessage object to delete.   
openChannel.deleteMessage(BASE_MESSAGE, new BaseChannel.DeleteMessageHandler() {
    @Override
    public void onResult(SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

The onMessageDeleted() method of a channel event handler will receive a callback from the server when a message is deleted, and the result also notified to all other participants in the channel, including who has deleted their own message.

Light Color Skin
Copy
SendBird.addChannelHandler(UNIQUE_HANDLER_ID, new SendBird.ChannelHandler() {
    ...
    
    @Override
    public void onMessageDeleted(BaseChannel channel, long messageId) {
    
    }
    ...

});

Retrieve a list of participants

You can retrieve a list of participants who are currently online and receiving all messages from an open channel.

Light Color Skin
Copy
ParticipantListQuery participantListQuery = openChannel.createParticipantListQuery();
participantListQuery.next(new UserListQuery.UserListQueryResultHandler() {
    @Override
    public void onResult(List<User> list, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

Retrieve the latest information on participants

To retrieve the latest and updated information on each online participant in an open channel, you need another ParticipantListQuery instance for the channel. Like the Retrieve a list of participants section above, create a query instance using the channel.createParticipantListQuery(), and then call its next() method consecutively to retrieve the latest.

You can also retrieve the latest and updated information on users at the application level. Like the Retrieve a list of users section, create a new ApplicationUserListQuery instance using the SendBird.createApplicationUserListQuery(), and then call its next() method consecutively to retrieve the latest.

When retrieving the online (connection) status of a user, by calling the user.getConnectionStatus() at each User object in a returned list, you can get the user's current connection status. The getConnectionStatus() returns one of the following two values:

  • User.ConnectionStatus.OFFLINE: the user is not connected to SendBird server.
  • User.ConnectionStatus.ONLINE: the user is connected to SendBird server.

Note: If you need to keep track of the connection status of some users in real time, we recommend that you call periodically the next() method of an ApplicationUserListQuery instance with its userIdsFilter filter specified, perhaps in intervals of one minute or more.


Retrieve a list of operators

You can follow the simple implementation below to retrieve a list of operators who monitor and control the activities in an open channel.

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
        // Retrieving a list of operators.
        for (User operator : openChannel.getOperators()) {
            ...
        }
    }
});

Retrieve a list of banned or muted users

You can create a query to get a list of banned or muted users in an open channel. This query is only available for users who are registered as operators of an open channel.

Light Color Skin
Copy
// Retrieving banned users 
BannedUserListQuery bannedUserListQuery = openChannel.createBannedUserListQuery(); 
bannedUserListQuery.next(new UserListQuery.UserListQueryResultHandler() {
    @Override
    public void onResult(List<User> list, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

// Retrieving muted users 
MutedUserListQuery mutedUserListQuery = openChannel.createMutedUserListQuery();
mutedUserListQuery.next(new UserListQuery.UserListQueryResultHandler() {
    @Override
    public void onResult(List<User> list, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
    }
});

Ban and unban a user

Operators of an open channel can remove any users that behave inappropriately in the channel by using our Ban feature. Banned users are immediately expelled from a channel and allowed to participate in the channel again after the time period set by the operators. Operators can ban and unban users from open channels using the following code.

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }

        // Banning and unbanning a user 
        if (openChannel.isOperator(SendBird.getCurrentUser())) {
            openChannel.banUser(USER, SECONDS, new OpenChannel.OpenChannelBanHandler() {
                @Override
                public void onResult(SendBirdException e) {
                    if (e != null) {    // Error.
                        return;
                    }

                    // TODO: Custom implementation for what to do after banning.
                }
            });
            
            openChannel.unbanUser(USER, new OpenChannel.OpenChannelUnbanHandler() {
                @Override
                public void onResult(SendBirdException e) {
                    if (e != null) {    // Error.
                        return;
                    }
                    
                    // TODO: Custom implementation for what to do after unbanning.
                }
            });
        }
    }       
});

Note: You can also use banUserWithUserId() and unbanUserWithUserID() methods, instead of banUser() and unbanUser() methods, as they have the same abilities.


Mute and unmute a user

Operators of an open channel can prohibit the selected users from sending messages using our Mute feature. Muted users remain in the channel and are allowed to view the messages, but can't send any messages until the operators unmute them. Operators can mute and unmute users in open channels using the following code:

Light Color Skin
Copy
OpenChannel.getChannel(CHANNEL_URL, new OpenChannel.OpenChannelGetHandler() {
    @Override
    public void onResult(OpenChannel openChannel, SendBirdException e) {
        if (e != null) {    // Error.
            return;
        }
        
        // Muting and unmuting a user 
        if (openChannel.isOperator(SendBird.getCurrentUser())) {
            openChannel.muteUser(USER, new OpenChannel.OpenChannelMuteHandler() {
                @Override
                public void onResult(SendBirdException e) {
                    if (e != null) {    // Error.
                        return;
                    }
    
                    // TODO: Custom implementation for what to do after muting.
                }
            });
            
            openChannel.unmuteUser(USER, new OpenChannel.OpenChannelUnmuteHandler() {
                @Override
                public void onResult(SendBirdException e) {
                    if (e != null) {    // Error.
                        return;
                    }
                    
                    // TODO: Custom implementation for what to do after unmuting.
                }
            });
        }
    }
});

Note: You can also use muteUserWithUserId() and unmuteUserWithUserID() methods, instead of muteUser() and unmuteUser() methods, as they have the same abilities.


Report a message, a user, or a channel

In an open channel, a user can report suspicious or harrassing messages as well as the other users who use abusive language. The user can also report channels if there are any inappropriate content or activity within the channel. Based on this feature and our report API, you can build your own in-app system for managing objectionable content and subject.

Light Color Skin
Copy
// Reporting a message
openChannel.reportMessage(MESSAGE_TO_REPORT, REPORT_CATEGORY, DESCRIPTION, new BaseChannel.ReportMessageHandler() {
    @Override
    public void onResult(SendBirdException e) {
        if (e != null) {    // Error.
            return; 
        }
    }
});

// Reporting a user
openChannel.reportUser(OFFENDING_USER, REPORT_CATEGORY, DESCRIPTION, new BaseChannel.ReportUserHandler() {
    @Override
    public void onResult(SendBirdException e) {
        if (e != null) {    // Error.
            return; 
        }
    }
});

// Reporting a channel
openChannel.report(REPORT_CATEGORY, DESCRIPTION, new BaseChannel.ReportHandler() {
    @Override
    public void onResult(SendBirdException e) {
        if (e != null) {    // Error.
            return; 
        }
    }
});
ParameterTypeDescription

MESSAGE_TO_REPORT

object

Specifies the message to report for its suspicious, harassing, or inappropriate content.

OFFENDING_USER

object

Specifies the user who uses offensive or abusive language such as sending explicit messages or inappropriate comments.

REPORT_CATEGORY

enum

Specifies a report category which indicates the reason for reporting. Acceptable values are limited to ReportCategory.SUSPICIOUS, ReportCategory.HARASSING, ReportCategory.INAPPROPRIATE, and ReportCategory.SPAM.

DESCRIPTION

string

Specifies additional information to include in the report.