---
source_url: https://www.pubnub.com/docs/sdks/android/api-reference/message-actions
title: Message Actions API for Android SDK
description: Learn to add and remove message actions with PubNub Android SDK to enhance chat features like receipts and custom metadata.
updated_at: 2026-11-09T13:29:01.000Z
---

# Message Actions API for Android SDK

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

:::warning Unsupported docs
PubNub no longer maintains Android SDK docs, but our [Java SDK](https://www.pubnub.com/docs/sdks/java.md) or [Kotlin SDK](https://www.pubnub.com/docs/sdks/kotlin.md) are fully compatible with the Android platform and you can use them to build mobile apps, ensuring stable software development.
:::

Use message actions to add or remove metadata on published messages. Common uses include receipts and reactions. Clients subscribe to a channel to receive message action events. Clients can also fetch past message actions from Message Persistence, either on demand or when fetching original messages.

:::tip Reactions
"Message Reactions" is a specific application of the Message Actions API for emoji or social reactions.
:::

:::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.md) and [Chat](https://www.pubnub.com/docs/chat/overview.md) 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 message action

:::warning Requires Message Persistence
Enable Message Persistence for your key in the [Admin Portal](https://admin.pubnub.com/) as described in [Enable the features your app calls](https://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

Add an action to a published message. The response includes the added action.

### Method(s)

Use this Android method:

```java
this.pubnub.addMessageAction()
    .channel(String)
    .messageAction(PNMessageAction);
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| channel | String | Yes | Channel name to add the message action to. |
| messageAction | PNMessageAction | Yes | Message action payload (type, value, message timetoken). |
| async | PNCallback | Yes | Callback of type `PNAddMessageActionResult`. |

### Sample code

```java
pubnub.addMessageAction()
        .channel("my_channel")
        .messageAction(new PNMessageAction()
                .setType("reaction")
                .setValue("smiley_face")
                .setMessageTimetoken(15701761818730000L)
        )
        .async(new PNCallback<PNAddMessageActionResult>() {
            @Override
            public void onResponse(PNAddMessageActionResult result, PNStatus status) {
                if (!status.isError()) {
                    System.out.println(result.getType());
                    System.out.println(result.getValue());
                    System.out.println(result.getUuid());
                    System.out.println(result.getActionTimetoken());
                    System.out.println(result.getMessageTimetoken());
                } else {
                    status.getErrorData().getThrowable().printStackTrace();
                }
            }
        })
```

### Returns

The `addMessageAction()` operation returns a `PNAddMessageActionResult` which contains the following operations:

| Method | Type | Description |
| --- | --- | --- |
| getType() | String | Message action type. |
| getValue() | String | Message action value. |
| getUuid() | String | Publisher of the message action. |
| getActionTimetoken() | Long | Timestamp when the message action was created. |
| getMessageTimetoken() | Long | Timestamp when the message was created that the action belongs to. |

#### PNMessageAction

| Method | Type | Description |
| --- | --- | --- |
| setType() | String | Message action type. |
| setValue() | String | Message action value. |
| setMessageTimetoken() | Long | Timetoken of the target message. |

## Remove message action

:::warning Requires Message Persistence
Enable Message Persistence for your key in the [Admin Portal](https://admin.pubnub.com/) as described in [Enable the features your app calls](https://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

Remove a previously added action from a published message. The response is empty.

### Method(s)

Use this Android method:

```java
this.pubnub.removeMessageAction()
    .channel(String)
    .messageTimetoken(Long)
    .actionTimetoken(Long);
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| channel | String | Yes | Channel name to remove the message action from. |
| messageTimetoken | Long | Yes | Timetoken of the target message. |
| actionTimetoken | Long | Yes | Timetoken of the message action to remove. |
| async | PNCallback | Yes | Callback of type `PNRemoveMessageActionResult`. |

### Sample code

```java
pubnub.removeMessageAction()
        .channel("my_channel")
        .messageTimetoken(15701761818730000L)
        .actionTimetoken(15701775691010000L)
        .async(new PNCallback<PNRemoveMessageActionResult>() {
            @Override
            public void onResponse(PNRemoveMessageActionResult result, PNStatus status) {
                if (!status.isError()) {
                    // result has no actionable data
                    // it's enough to check if the status itself is not an error
                } else {
                    status.getErrorData().getThrowable().printStackTrace();
                }
            }
        });
```

### Returns

The `removeMessageAction()` operation returns no actionable data.

## Get message actions

:::warning Requires Message Persistence
Enable Message Persistence for your key in the [Admin Portal](https://admin.pubnub.com/) as described in [Enable the features your app calls](https://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

Get a list of message actions in a channel. The response sorts actions by the action timetoken in ascending order.

:::note Truncated response
The number of message actions in the response may be truncated when internal limits are hit. If the response is truncated, a `more` property is returned with additional parameters. Send iterative calls to Message Persistence, adjusting the parameters to fetch more message actions.
:::

:::warning How to use the start and end parameters
PubNub retrieves messages by searching **backward through time** (newest to oldest). Because of this, the parameter names are the reverse of their intuitive meaning:
* **start** is the **newer** boundary (higher timetoken value) - search begins here, **exclusive**
* **end** is the **older** boundary (lower timetoken value) - search stops here, **inclusive**
When you provide both parameters, `start` must be a **higher** timetoken than `end`.
```mermaid
graph LR
    A(["9:00 AM<br/>(oldest)"]) -->|"time flows →"| B["end = 10:00 AM<br/>older boundary<br/>inclusive ✓"]
    B --> C["messages<br/>retrieved"]
    C --> D["start = 11:00 AM<br/>newer boundary<br/>exclusive ✗"]
    D -->|"time flows →"| E(["11:59 AM<br/>(newest)"])
    D -.->|"◄ API searches backward"| B
    style A fill:#f8f9fa,stroke:#6c757d,color:#495057
    style E fill:#f8f9fa,stroke:#6c757d,color:#495057
    style B fill:#d4edda,stroke:#28a745,color:#000
    style C fill:#cce5ff,stroke:#004085,color:#000
    style D fill:#fff3cd,stroke:#856404,color:#000
```
9:00 AM10:00 AM11:00 AM11:59 AM
Results are always returned in oldest-first order.
:::

### Method(s)

Use this Android method:

```java
this.pubnub.getMessageActions()
    .channel(String)
    .start(Long)
    .end(Long)
    .limit(Integer);
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | String | Yes | n/a | Channel name to list message actions for. |
| start | Long | Optional | n/a | Newer boundary of the query (exclusive). Must be a higher timetoken value than `end` when both are provided. |
| end | Long | Optional | n/a | Older boundary of the query (inclusive). Must be a lower timetoken value than `start` when both are provided. |
| limit | Integer | Optional | `100` | Maximum number of actions to return. Default/Maximum is `100`. |
| async | PNCallback | Yes | n/a | Callback of type `PNGetMessageActionsResult`. |

### Sample code

```java
pubnub.getMessageActions()
        .channel("my_channel")
        .async(new PNCallback<PNGetMessageActionsResult>() {
            @Override
            public void onResponse(PNGetMessageActionsResult result, PNStatus status) {
                if (!status.isError()) {
                    List<PNMessageAction> actions = result.getActions();
                    for (PNMessageAction action : actions) {
                        System.out.println(action.getType());
                        System.out.println(action.getValue());
                        System.out.println(action.getUuid());
                        System.out.println(action.getActionTimetoken());
                        System.out.println(action.getMessageTimetoken());
                    }
                } else {
                    status.getErrorData().getThrowable().printStackTrace();
                }
            }
        });
```

### Returns

The `getMessageActions()` operation returns a list of `PNGetMessageActionsResult` objects, each containing the following operations:

| Method | Type | Description |
| --- | --- | --- |
| getType() | String | Message action type. |
| getValue() | String | Message action value. |
| getUuid() | String | Publisher of the message action. |
| getActionTimetoken() | Long | Timestamp when the message action was created. |
| getMessageTimetoken() | Long | Timestamp when the message was created that the action belongs to. |

### Other examples

#### Fetch messages with paging

```java
public static void main(String args[]){
    getMessageActionsWithPaging("my_channel", System.currentTimeMillis() * 10_000L, new Callback() {
            @Override
            public void onMore(List<PNMessageAction> actions) {
                System.out.println("Next set of actions: " + actions.size());
            }

            @Override
            public void onDone() {
                System.out.println("All actions fetched");
            }
        });
}

/**
    * Fetches 5 message actions at a time, recursively and in a paged manner.
    *
    * @param channel  The channel where the message is published, to fetch message actions from.
    * @param start    The timetoken which indicates from where to start fetching message actions.
    * @param callback The callback to dispatch fetched message actions to.
    */
static void getMessageActionsWithPaging(String channel, Long start, Callback callback) {
    pubnub.getMessageActions()
            .channel(channel)
            .start(start)
            .limit(5)
            .async(new PNCallback<PNGetMessageActionsResult>() {
                @Override
                public void onResponse(PNGetMessageActionsResult result, PNStatus status) {
                    if (!status.isError() && !result.getActions().isEmpty()) {
                        callback.onMore(result.getActions());
                        getMessageActionsWithPaging(channel,
                            result.getActions().get(0).getActionTimetoken(), callback);
                    } else {
                        callback.onDone();
                    }
                }
            });
}

interface Callback {
    void onMore(List<PNMessageAction> actions);

    void onDone();
}
```

Last updated at: 2026-11-09T13:29:01.000Z
