ButtonMerchant
@objcMembers
final public class ButtonMerchant : NSObject
Note
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
attributionTokenfrom 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
public static func configure(applicationId: String)Parameters
applicationIdYour 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
urlanduserActivityfrom the followingUIApplicationDelegatemethods:application(_:open:options:)application(_:userActivity:restorationHandler:)
Declaration
Swift
public static func trackIncomingURL(_ url: URL)Parameters
urlA URL that has entered your app from a third party source.
-
Checks the URL in the passed NSUserActivity for Button attribution and if present stores the token.
Attention
To correctly attribute customers, you must call this method with every incoming
userActivityfrom the followingUIApplicationDelegatemethod:application(_:userActivity:restorationHandler:)
Declaration
Swift
public static func trackIncomingUserActivity(_ userActivity: NSUserActivity)Parameters
userActivityA NSUserActivity with which your app has been continued.
-
Checks to see if the user visited a url destined for your app 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 if one is found. All subsequent incoming urls will be routed to your
UIApplicationDelegateas usual.Declaration
Swift
public static func handlePostInstallURL(_ completion: @escaping (URL?, Error?) -> Void)Parameters
completionA completion block taking an optional url and optional error.
-
Reports an order to Button.
See also
Declaration
Swift
public static func reportOrder(_ order: Order, completion: ((Error?) -> Void)? = nil)Parameters
orderYour order object to be reported.
completionAn optional completion block taking an optional error.
-
Discards the current session and all persisted data.
Declaration
Swift
public static func clearAllData() -
An interface through which library features can be enabled/disabled.
Declaration
Swift
@objc public static var features: Configurable { get } -
An interface through which user activity can be reported.
Declaration
Swift
@objc public static var activity: Activity { get }
ButtonMerchant Class Reference