Chat UIKit Android View v3
Chat UIKit Android View
Chat UIKit
Android View
Version 3

Reactions

Copy link

Message reactions are a useful social interaction tool that helps build a more engaging chat experience. Users can express their response to messages beyond text using emojis. The UIKit reactions feature is based on the Chat SDK’s reactions feature and provides a default set of emojis suited for diverse messaging needs. You can also customize the reactions UI just like the global themes.

Note: Reactions are currently only available for group channels. This feature isn't supported in open channels, Supergroup channels, and custom message types.


Implementation guide for reactions

Copy link

Once a client app is connected to the Sendbird server, you can access the predefined emoji list. A combination of the emoji list and the reaction information within each message completes the UI of the reactions.

In order to implement this feature, the following settings need to be checked:

  • The application settings for reactions
  • The emojis registered in your Sendbird application

Components

Copy link

There are 3 ways in which reactions can be expressed by users:

  • Long tap on a message to select an emoji from the Emoji reaction bar.
  • Tap on the Add reaction button to select an emoji.
  • Tap on an existing emoji reaction in the Emoji reaction box to add a user count of the reaction.

Emoji reaction bar in Message menu

Copy link

When a message doesn't contain any prior reaction data, the only way to add a reaction is by holding down a message to view the Emoji reaction bar in the Message menu. The bar reveals a list of five to six emojis in the chronological order of when each emoji was registered to the Sendbird server. Selecting the Add reaction button on the right end of the bar reveals the full Emoji list to add different emoji reactions.

If a message already contains reaction data, you can still long tap a message to view the Emoji reaction bar. In this case, emoji reactions already added to the message by the current user are indicated with a highlighted background color.

Add reaction button

Copy link

The Add reaction button can be accessed through either the Emoji reaction box or the Emoji reaction bar in the Message menu.

A long tap on a message can open the Emoji reaction bar where the Add reaction button appears, whereas a regular tap on the button in the Emoji reaction box sends an onClick() event that calls the Emoji list.

Emoji list

Copy link

An Emoji list displays all emojis registered within an application. By default, Sendbird UIKit provides seven emojis but you can register more through the add emojis API. The Emoji list is refreshed when the application connects to the Chat SDK by comparing the prior emojiHash in the application to the emojiHash information from the Sendbird server.

When the Emoji list is shown, reactions already added to a message by the current user are indicated with a highlighted background color.

Emoji reaction box

Copy link

When a text or file message contains reaction data, this data is displayed below the message in the form of emoji reactions. The number of users who added an emoji reaction to the message is indicated next to each emoji reaction. Selecting an emoji in the Emoji reaction box adds or removes the reacted user count.

Reacted user list

Copy link

To see a list of users who reacted to the message, long tap a reaction emoji that's displayed in the Emoji reaction box. The underlined tab corresponds to the tapped emoji reaction but you can also view the reacted user list for other emoji reactions. Each tab shows the user count and a list of all users who reacted with the emoji.


Customize the reactions UI

Copy link

The following code shows how to build ChannelFragment with the reactions-related methods of fragment.builder().

KotlinJava
val fragment = ChannelFragment.Builder("CHANNEL_URL")
    .setEmojiReactionClickListener(emojiReactionClickListener)
    .setEmojiReactionLongClickListener(emojiReactionLongClickListener)
    .setEmojiReactionMoreButtonClickListener(emojiReactionMoreButtonClickListener)
    .build()

Style resource

Copy link

To customize the style of reactions, you have to change UIKit-defined style values in the res/values/style.xml file as shown below. To learn how to customize style, refer to the style resource.

<style name="Widget.Sendbird.Message.Me">
</style>
<style name="Widget.Sendbird.Message.Other">
</style>
<style name="Widget.Sendbird.Emoji">
</style>

Event handler for reaction

Copy link

UIKit supports an event handler for all tap gestures related to the reactions UI. When the current user taps or long taps on views for the reaction feature, the setOnEmojiReactionClickListener(), setOnEmojiReactionLongClickListener() or setOnEmojiReactionMoreButtonClickListener() method of MessageListComponent is called. To learn how to customize message click events, see this page.

MethodDescription

setOnEmojiReactionClickListener(OnEmojiReactionClickListener)

Called when the emoji reaction is tapped and redirects the current user to the original message and the key of the reaction.

setOnEmojiReactionLongClickListener(OnEmojiReactionLongClickListener)

Called when the emoji reaction is long pressed and redirects the current user to the original message and the key of the reaction.

setOnEmojiReactionMoreButtonClickListener(OnItemClickListener)

Called when the more button of the emoji reaction is pressed and redirects the current user to the original message in the channel.