public final class

Button

extends Object
java.lang.Object
   ↳ com.usebutton.sdk.Button

Class Overview

Main entry point to the Button SDK.

Summary

Nested Classes
class Button.InvalidAppIdException Exception class when an Application id is invalid. 
interface Button.OnConfigureListener Completion listener for configure(Context, String, OnConfigureListener)
Public Constructors
Button()
Public Methods
static ButtonActionsInterface actions()
This method is deprecated. Button Actions has been deprecated. Please contact Button to update your integration.
static Boost boost()
static void clearAllData()
Discards the current session and all persisted data.
static Configuration configuration()
Button SDK feature configuration.
static void configure(Context context, String applicationId)
Configures Button with your application id.
static void configure(Context context, String applicationId, Button.OnConfigureListener listener)
Configures Button with your application id.
static DebugInterface debug()
Debug the Button SDK.
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.
static void openURL(String url, String title, OnUrlOpenedListener listener)
static void openURL(String url, String title, String subtitle, OnUrlOpenedListener listener)
static void openURL(String url)
Asynchronously open a given URL.
static void openURL(String url, BrowserConfig config, OnBrowserOpenedListener listener)
Asynchronously open a given URL.
static void openURL(String url, OnBrowserOpenedListener listener)
Asynchronously open a given URL.
static void openURL(String url, OnUrlOpenedListener listener)
static void openURL(String url, BrowserConfig config)
Asynchronously open a given URL.
static Personalization personalization()
Personalize your user's experience.
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.
static User user()
Associate your user with a Button session.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Button ()

Public Methods

public static ButtonActionsInterface actions ()

This method is deprecated.
Button Actions has been deprecated. Please contact Button to update your integration.

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.

See https://developer.usebutton.com/guides/publishers/android/using-button-actions

{@code
 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);
         }
     }
 });
 }</pre>

Returns
  • Button Actions API

public static Boost boost ()

Returns
  • Boost API

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
  • Button configuration API

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
  • Button debug API

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.

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
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.

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
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.

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
listener optional completion listener

public static void openURL (String url, BrowserConfig config)

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
config the configuration object used to change title, set pub-ref etc.

public static Personalization personalization ()

Personalize your user's experience.

Returns
  • Button Personalization API

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.

See https://developer.usebutton.com/guides/publishers/android/create-a-button-purchase-path

{@code
 PurchasePathRequest request = new PurchasePathRequest("https://www.example.com/");
 Button.purchasePath().fetch(request, new ActionListener() {@Override
     public void onComplete(@Nullable PurchasePath action, @Nullable Throwable t) {
         if (action != null) {
             action.start(context);
         }
     }
 });
 }</pre>

Returns
  • Purchase Path API

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.

See https://developer.usebutton.com/guides/publishers/configure-webhooks.

 Button.user().setIdentifier(myLoggedInUser.identifier);
 

Returns
  • Button user API