---
title: "Handling button clicks"
slug: "mobile-handling-button-clicks"
updated: 2026-06-09T22:56:40Z
published: 2026-06-09T22:56:40Z
canonical: "docs.xtremepush.com/mobile-handling-button-clicks"
stale: true
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xtremepush.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handling button clicks

Implementation required for interactive mobile push notifications

With the [push category](/documentation/docs/push-categories) capability you can add multiple buttons to your messages. It's then required to handle different buttons clicks. It could be done using our message response handler.

## iOS

**Swift**

```swift
XPush.registerContinousMessageResponseHandler({(_ response: XPMessageResponse, _ callback: XPMessageCompletionBlock) -> Void in
        if response.action.type == XPActionType_Click {
            //like button which runs in background
            if(response.action.identifier == "like"){
                likeArticle(response.message.data["articleId"])
            } 
            //View button which runs in foreground
            else if(response.action.identifier == "view"){
                openArticle(response.message.data["articleId"])
            }
        }
        //if nothing to be done
        completionHandler()
 })
```

**Objective-C**

```objectivec
[XPush registerMessageResponseHandlerWithCompletion:^(XPMessageResponse * _Nonnull x, XPMessageCompletionBlock  _Nonnull completionHandler) {
    if (response.action.type == XPActionType_Click) {
        switch (response.action.identifier) {
            // Like button which runs in background
            case "like": 
                // Like article asynchronously and call completionHandler when finished
                [self likeArticle: response.message.data[@"articleId"] completionHandler: completionHandler];
                return;
            // View button which runs in foreground
            case "view":
                // Navigate to the article page
                [self openArticle: response.message.data[@"articleId"]];
                completionHandler();
                return;
        }
    }
    // If nothing to be done
    completionHandler();
}];
```

## Android

Implement the `MessageResponseListener` in your Application.java class

```java
public class YOUR_APPLICATION_CLASS extends Application implements MessageResponseListener {
```

```java
@Override
    public void messageResponseReceived(Message messagePayload,
                                        HashMap<String, String> responsePayload,
                                        WeakReference uiReference) {

        if(responsePayload.get("responseType").equals("click")){
            switch (responsePayload.get("action")){
                // Like button which runs in background
                case "like":
                    //like article asynchronously
                    likeArticle(messagePayload.data.get("articleId"));
                    break;
                // View button which runs in foreground
                case "view":
                    //navigate to article page
                    //note, uiReference and uiReference.get() need to checked to ensure
                    //   they are not null
                    goToArticle(uiReference, messagePayload.data.get("articleId"));
                    break;
            }
        }
    }
```

Then add the `setMessageResponseListener` option to your initialisation of the PushConnector:

```java
new PushConnector.Builder(XPUSH_APP_KEY, GOOGLE_PROJECT_NUMBER)
            .setMessageResponseListener(this)
            ...
            .create(this);
```
