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()
Buttons provide relevant actions to your users, complete with a corresponding UI.
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, Button.OnConfigureListener listener)
Configures Button with your application id.
static void configure(Context context, String applicationId)
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 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 ()

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