---
source_url: https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/reactions
title: Reactions
updated_at: 2026-06-15T12:11:33.864Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Reactions

Manage emoji reactions on messages in your Chat SDK app. Users can add, remove, and view reactions on any message.

:::note Message Actions vs. Message Reactions
**Message Actions** is the flexible, low-level API for adding any metadata to messages (read receipts, delivery confirmations, custom data), while **Message Reactions** specifically refers to using Message Actions for emoji/social reactions.
In PubNub [Core](https://www.pubnub.com/docs/sdks) and [Chat](https://www.pubnub.com/docs/chat/overview) SDKs, the same underlying Message Actions API is referred to as **Message Reactions** when used for emoji reactions - it's the same functionality, just different terminology depending on the use case.
:::

## Add & delete

`toggleReaction()` is a method for both adding and removing message reactions. It adds a string flag to the message if the current user hasn't added it yet or removes it if the current user already added it before.

If you use this method to add or remove message reactions, this flag would be a literal emoji you could implement in your app's UI. However, you could also use this method for a different purpose, like marking a message as pinned to a channel or unpinned if you implement the [pinning feature](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/pinned) in your chat app.

### Method signature

This method takes the following parameters:

```kotlin
message.toggleReaction(reaction: String): PNFuture<Message>
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| reaction | String | Yes |  | Emoji added to the message or removed from it by the current user. |

#### Output

| Type | Description |
| --- | --- |
| `PNFuture<Message>` | Updated message instance with an added `reactions` action type. |

### Sample code

Add the "thumb up" emoji (`\u{1F44D}`) to the last message on the `support` channel.

```kotlin
        val channel: Channel
        // ...

        channel.getHistory(count = 1).async { result ->
            result.onSuccess { history ->
                history.messages.firstOrNull()?.let { message ->
                    message.toggleReaction("👍").async {
                        it.onSuccess { newMessage ->
                            // success - the returned message needs to replace an existing message in your app’s message list
                        }.onFailure {
                            // failure
                        }
                    }
                }
            }.onFailure {
                // handle failure
            }
        }
```

## Get updates

To learn how to receive updates whenever a message reaction is added, edited, or removed on other clients, head to the [Get updates](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/updates#get-message-updates) section.

## Get reactions for one message

`reactions` returns a list of `MessageReaction` objects for the message. Each reaction contains the emoji `value`, whether the current user added it (`isMine`), the list of `userIds` who added it, and the total `count`.

### Sample code

List all reactions added to the last message on the `support` channel.

```kotlin
val channel: Channel
// ...

// fetch the last message
channel.getHistory(count = 1).async { result ->
    result.onSuccess { historyResult ->
        if (historyResult.messages.isNotEmpty()) {
            val lastMessage = historyResult.messages.first()
            val reactions = lastMessage.reactions
            if (reactions.isNotEmpty()) {
                reactions.forEach { reaction ->
                    println("Reaction: ${reaction.value} by ${reaction.userIds} (count: ${reaction.count}, mine: ${reaction.isMine})")
                }
            } else {
                println("No reactions on the last message.")
            }
        } else {
            println("No messages in the channel.")
        }
    }.onFailure { exception: PubNubException ->
        println("An error occurred: ${exception.message}")
    }
}
```

## Get historical reactions

If you have [Message Persistence](https://www.pubnub.com/docs/sdks/kotlin/api-reference/storage-and-playback) enabled on your keyset, PubNub stores all historical info about messages, their metadata, and reactions.

If you want to fetch historical info about message reactions, use the [getHistory()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/history) method. By default, when you fetch historical messages, PubNub returns all message reactions and metadata attached to the retrieved messages.

## Check

`hasUserReaction()` checks if the current user added a given emoji to the message.

### Method signature

This method takes the following parameters:

```kotlin
message.hasUserReaction(reaction: String): Boolean
```

#### Input

| Parameter | Description |
| --- | --- |
| `reaction` *Type: `String`Default: n/a | Specific emoji added to the message. |

#### Output

| Type | Description |
| --- | --- |
| `Boolean` | Specifies if the current user added a given emoji to the message or not. |

### Sample code

Check if the current user added the "thumb up" emoji (👍) to the last message on the `support` channel.

```kotlin
val channel: Channel
// ...

// fetch the last message
channel.getHistory(count = 1).async { result ->
    result.onSuccess { historyResult ->
        if (historyResult.messages.isNotEmpty()) {
            val lastMessage = historyResult.messages.first()
            val thumbUpEmoji = "👍"

            val hasThumbUpReaction = lastMessage.hasUserReaction(thumbUpEmoji)
            if (hasThumbUpReaction) {
                println("The current user has added the 'thumb up' emoji to the last message.")
            } else {
                println("The current user has not added the 'thumb up' emoji to the last message.")
            }
        } else {
            println("No messages in the channel.")
        }
    }.onFailure { exception: PubNubException ->
        println("An error occurred: ${exception.message}")
    }
}
```