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
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
anduserActivity
from the followingUIApplicationDelegate
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 Button attribution and if present stores the token.
Attention
To correctly attribute customers, you must call this method with every incoming
userActivity
from the followingUIApplicationDelegate
method:application(_:userActivity:restorationHandler:)
Declaration
Swift
@objc public static func trackIncomingUserActivity(_ userActivity: NSUserActivity)
Parameters
userActivity
A 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
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
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 }
-
An interface through which user activity can be reported.
Declaration
Swift
@objc public static var activity: Activity { get }