ButtonMerchant

@objcMembers
final public class ButtonMerchant : NSObject

ButtonMerchant is the main entry point to the library.

To get started with your integration, get your application Id from from the Button Dashboard. and follow our simple integration guide

  • The last tracked attributionToken from an inbound Button attributed URL.

    Attention

    For attribution to work correctly, you must:
    • Always access this token directly—never cache it.
    • Never manage the lifecycle of this token—Button manages the token validity window server-side.
    • Always include this value when reporting orders to your order API

    Declaration

    Swift

    @objc
    public static var attributionToken: String? { get }
  • Configures ButtonMerchant with your application Id.

    Note

    Get your application Id from from the Button Dashboard

    Declaration

    Swift

    @objc
    public static func configure(applicationId: String)

    Parameters

    applicationId

    Your application Id (required)

  • Checks the passed URL for a Button attribution and if present stores the token.

    Attention

    To correctly attribute customers, you must call this method with every incoming url and userActivity from the following UIApplicationDelegate methods:

    • application(_:open:options:)

    • application(_:userActivity:restorationHandler:)

    Declaration

    Swift

    @objc
    public static func trackIncomingURL(_ url: URL)

    Parameters

    url

    A URL that has entered your app from a third party source.

  • Checks the URL in the passed NSUserActivity for a Button attribution and if present stores the token.

    Attention

    To correctly attribute customers, you must call this method with every incoming userActivity from the following UIApplicationDelegate method:

    • application(_:userActivity:restorationHandler:)

    • userActivity: A NSUserActivity with which your app has been continued.

    Declaration

    Swift

    @objc
    public static func trackIncomingUserActivity(_ userActivity: NSUserActivity)
  • Checks to see if the user visited a url prior to installing your app.

    If a url is found, your completion handler will be called with the url and you are responsible for navigating the user to the relevant content in your app. If a url is not found or an error occurs, your completion handler will be called without a url and you can continue with your normal launch sequence.

    Attention

    This method checks for a post-install url exactly one time after a user has installed your app. Subsequent calls will result in your completion handler being called without a url. You do not need to wait for the completion handler before continuing with your normal launch sequence but you should be prepared to handle a post-install url is one is found. All subsequent incoming urls will be routed to your UIApplicationDelegate as usual.

    Declaration

    Swift

    @objc
    public static func handlePostInstallURL(_ completion: @escaping (URL?, Error?) -> Void)

    Parameters

    completion

    A completion block taking an optional url and optional error.

  • Reports an order to Button.

    See also: Reporting Orders to Button (docs)

    Declaration

    Swift

    @objc
    public static func reportOrder(_ order: Order, completion: ((Error?) -> Void)? = nil)

    Parameters

    order

    Your order object to be reported.

    completion

    An optional completion block taking an optional error.

  • Discards the current session and all persisted data.

    Declaration

    Swift

    @objc
    public static func clearAllData()
  • An interface through which library features can be enabled/disabled.

    Declaration

    Swift

    @objc
    public static var features: Configurable { get }

Deprecations

  • Deprecated.

    This method is deprecated and will be removed in a future version. It is safe to remove your usage of this method.

    Declaration

    Swift

    @available(*, deprecated, message: "No longer supported. You can safely remove your usage of this method.")
    @objc
    public static func trackOrder(_ order: Order, completion: ((Error?) -> Void)? = nil)