---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/reactions
title: Reactions
updated_at: 2026-06-01T12:02:10.332Z
---

> 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()` adds or removes a message reaction. It adds a string flag if the current user hasn't added it yet, or removes it if already added.

Use this method for emoji reactions or other purposes like [pinning messages](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/pinned) to channels.

### Method signature

This method takes the following parameters:

```csharp
message.ToggleReaction(string reactionValue)
```

#### Input

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

#### Output

An awaitable `Task<ChatOperationResult>`.

### Sample code

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

```csharp
using System.Linq;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// reference the "support" channel and ensure it's found
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.Log("Support channel not found.");
    return;
}
var channel = channelResult.Result;
Debug.Log($"Found channel with name {channel.Name}");

// get the message history with the desired count
var messageHistoryResult = await channel.GetMessageHistory(null, null, 1);
if (messageHistoryResult.Error)
{
    Debug.Log("Could not retrieve message history.");
    return;
}

// get the last message from the returned list
var lastMessage = messageHistoryResult.Result.FirstOrDefault();

if (lastMessage != null)
{
    // add the "thumb up" emoji to the last message
    await lastMessage.ToggleReaction("\\u{1F44D}");
    Debug.Log("Added 'thumb up' reaction to the last message.");
}
else
{
    Debug.Log("No messages found in the channel history.");
}
```

## 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/unity-chat-sdk/build/features/messages/updates#get-message-updates) section.

## Get reactions for one message

### Grouped reactions

`MessageReactions()` returns reactions grouped by value, with counts and user IDs. Use this to display aggregated reaction counts in your UI.

#### Method signature

```csharp
message.MessageReactions()
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `List<MessageReaction>` | A list of `MessageReaction` objects, each representing one reaction type with its value, whether the current user reacted, the list of user IDs, and a count. |

`MessageReaction` contains the following properties:

| Property | Description |
| --- | --- |
| `Value`Type: `string` | The reaction value (for example, an emoji like `👍`). |
| `IsMine`Type: `bool` | Whether the current user added this reaction. |
| `UserIds`Type: `List<string>` | All user IDs who gave this reaction. |
| `Count`Type: `int` | Number of users who gave this reaction (equal to `UserIds.Count`). |

### Raw reactions

`Reactions` returns all raw reactions added to a message (with the user ID and timetoken for each).

#### Method signature

```csharp
message.Reactions
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `List<MessageAction>` | A list of `MessageAction` objects, each containing details of a reaction including its type, value, timestamp, and the user ID of the person who added the reaction. |

### Sample code

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

```csharp
using System.Linq;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// reference the "support" channel and ensure it's found
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.Log("Support channel not found.");
    return;
}
var channel = channelResult.Result;
Debug.Log($"Found channel with name {channel.Name}");

// get the message history with the desired count
var messageHistoryResult = await channel.GetMessageHistory(null, null, 1);
if (messageHistoryResult.Error)
{
    Debug.Log("Could not retrieve message history.");
    return;
}

// get the last message from the returned list
var lastMessage = messageHistoryResult.Result.FirstOrDefault();

if (lastMessage != null)
{
    // output all reactions added to the last message (in MessageAction format)
    var reactions = lastMessage.Reactions;
    foreach (var reaction in reactions)
    {
        Debug.Log($"Reaction: {reaction.Value}");
    }

    // output all reactions added to the last message (in MessageReaction format)
    var messageReactions = lastMessage.MessageReactions();
    foreach (var messageReaction in messageReactions)
    {
        Debug.Log($"Reaction: {messageReaction.Value}, {messageReaction.Count}, {messageReaction.IsMine}");
        Debug.Log("Users who gave the reaction:");
        foreach (var id in messageReaction.UserIds)
        {
            Debug.Log(id);
        }
    }
}
else
{
    Debug.Log("No messages found in the channel history.");
}
```

## Get historical reactions

If you have [Message Persistence](https://www.pubnub.com/docs/sdks/unity/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 [GetMessageHistory()](https://www.pubnub.com/docs/chat/unity-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 reactions

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

### Method signature

This method takes the following parameters:

```csharp
message.HasUserReaction(string reactionValue)
```

#### Input

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

#### Output

| Type | Description |
| --- | --- |
| `bool` | Specifies if the message has the specified user reaction (`true`) or not (`false`). |

### Sample code

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

```csharp
using System.Linq;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// reference the "support" channel and ensure it's found
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.Log("Support channel not found.");
    return;
}
var channel = channelResult.Result;
Debug.Log($"Found channel with name {channel.Name}");

// get the message history with the desired count
var messageHistoryResult = await channel.GetMessageHistory(null, null, 1);
if (messageHistoryResult.Error)
{
    Debug.Log("Could not retrieve message history.");
    return;
}

// get the last message from the returned list
var lastMessage = messageHistoryResult.Result.FirstOrDefault();

if (lastMessage != null)
{
    // Check if the current user added the "thumb up" emoji to the last message
    if (lastMessage.HasUserReaction("\\u{1F44D}"))
    {
        Debug.Log("The current user has added a 'thumb up' reaction to the last message.");
    }
    else
    {
        Debug.Log("The current user has not added a 'thumb up' reaction to the last message.");
    }
}
else
{
    Debug.Log("No messages found in the channel history.");
}
```