Button | Button SDK for Android v7.0.0

Button

Main entry point to the Button SDK.

Summary

Nested Classes
class
interface
Public Constructors
Public Methods
static

ButtonActionsInterface
static

Boost
static

void
static

Configuration
static

void
static

void
static

DebugInterface
static

void
static

void
static

void
static

void
static

void
static

void
static

void
static

void
static

Personalization
static

PurchasePathInterface
static

User

Buttons provide relevant actions to your users, complete with a corresponding UI. Buttons can be configured with one or more merchants that they can offer to your users.

ActionQuery query = ActionQuery.withSubjectLocation(new Location(40.71, 74.0));
ActionRequest request = new ActionRequest("btn-abc123", query);
Button.actions().fetch(reservationRequest, new ActionListener() {@Override
    public void onComplete(@Nullable ButtonAction action, @Nullable Throwable t) {
        if (action != null) {
            action.start(context);
        }
    }
});

Returns

public static Boost boost()

Returns

public static void clearAllData()

Discards the current session and all persisted data.

Call this method in your log out handler if/when your user logs out of your app.

public static Configuration configuration()

Button SDK feature configuration.

Returns

public static void configure(Context context, String applicationId)

Configures Button with your application id.

This method should be called from your Application.onCreate().

Parameters

| context | Context you application context. | | applicationId | your Button application id found at https://app.usebutton.com/. |

public static void configure(Context context, String applicationId, Button.OnConfigureListener listener)

Configures Button with your application id. This method should be called from your Application.onCreate().

Parameters

| context | Context you application context. | | applicationId | your Button application id found at https://app.usebutton.com/. | | listener | optional callback when configuration is complete. |

public static DebugInterface debug()

Debug the Button SDK.

Enable debug logging during integration for more visibility.

if (BuildConfig.DEBUG) {
     Button.debug().setLoggingEnabled(true);
}
Returns

public static void onLocaleChanged(Context context)

Call this if you need to have the Button SDK reload its language settings from Locale.getDefault() (in case you're forcing a different language in your app from the device default.

public static void openURL( String url, String title, OnUrlOpenedListener listener)

This method is deprecated.

use openURL(String, BrowserConfig, OnBrowserOpenedListener).

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands. For such Brands, you may pass a title to provide your users with a cohesive experience.

Parameters

| url | the link to open | | title | optional browser title | | listener | optional completion listener |

public static void openURL( String url, String title, String subtitle, OnUrlOpenedListener listener)

This method is deprecated.

use openURL(String, BrowserConfig, OnBrowserOpenedListener).

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands. For such Brands, you may pass a title and subtitle to provide your users with a cohesive experience.

N.B. if you provide the subtitle, you must provide the title as well!

Parameters

| url | the link to open | | title | optional browser title | | subtitle | optional browser subtitle | | listener | optional completion listener |

public static void openURL( String url)

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands.

Parameters

| url | the link to open |

public static void openURL( String url, BrowserConfig config, OnBrowserOpenedListener listener)

Asynchronously open a given URL.

Parameters

| url | the link to open | | config | the configuration object used to change title, set pub-ref etc. | | listener | the completion listener |

public static void openURL( String url, OnBrowserOpenedListener listener)

Asynchronously open a given URL.

Parameters

| url | the link to open | | listener | the completion listener |

public static void openURL( String url, OnUrlOpenedListener listener)

This method is deprecated.

use openURL(String, BrowserConfig, OnBrowserOpenedListener).

Asynchronously open a given URL.

Parameters

| url | the link to open | | listener | optional completion listener |

public static void openURL( String url, BrowserConfig config)

Asynchronously open a given URL.

Parameters

| url | the link to open | | config | the configuration object used to change title, set pub-ref etc. |

public static Personalization personalization()

Personalize your user's experience.

Returns

public static PurchasePathInterface purchasePath()

Button Purchase Path takes regular merchant URLs to products, categories or just the homepage and replaces them with a fully attributed Button Purchase Path, optimized for both conversion and user experience.

Returns

public static User user()

Associate your user with a Button session.

You can associate all Button activity with one of your users by setting their user identifier. This can be your user ID, email or a stable hash of one. You can use this later to look up orders, activity and identify the user using Webhooks.