Android Web SDK Classes & Functions

Settings

Before starting the SDK, settings need to be defined. The AlloySettings class can be used to define the parameters for the SDK.

Usage

    val settings = AlloySettings(
        apiKey = "SDK_KEY",
        production = false,
        journeyToken = "J-bDaBxrAL46TA8zLc9a3E",
        journeyApplicationToken = "JA-Nfccb2O6Wk91U9JuHmbU"
    )

Parameters

The following parameters are supported in the AlloySettings class

KeyTypeRequiredDescription
apiKeystringrequiredThis is your Alloy SDK key. It can be found in the settings section of your Alloy dashboard
journeyTokenstringrequiredYour Journey Token can be grabbed from the Journey page on your Alloy dashboard
JourneyApplicationTokenstringoptional, required when using step-upSpecific application of a Journey
isSingleEntitybooleanoptionalUse this parameter if you want to send each entity their own portion of the step up process
entityTokenstringoptionalRequired if isSingleEntity is true.
externalEntityIdstringoptional
productionbooleanrequiredIndicates if you are hitting sandbox or prod API endpoints
colorjsonoptional
customStylejsonoptional



Start SDK

Once your settings have been configured, you can start the SDK with the start function

Usage

Alloy.start(this@MainActivity, settings)

Parameters

The following parameters are supported in the Alloy.start() function

KeyTypeRequiredDescription
activityouter scope referencerequiredThis is the outer scope reference of the activity the SDK is being used in
settingsclassrequiredThis is the class instance of AlloySettings



Listening for Events

The Alloy.Listener interface can be used to listen for events that occur during the lifecycle of the SDK. The following functions are supported

onSuccess()
Executes when the SDK completes, and the application reaches an approved outcome.

onManualReview()
Executes when the SDK completes, and the application reaches a manual review outcome.

onDenied()
Executes when the SDK completes, and the application reaches a denied outcome.

onCancelled()
Executes when the SDK is closed by the user.

gotError()
Executes when the SDK encounters and error such as failing to initialize.

Usage:
The Listener functions can be overridden to execute code as needed for your application. Below is a sample of overriding all the listener functions to debug log with AlloyDemo as a tag and the function name as the message.

Alloy.listener = object : Alloy.Listener {
            override fun onCancelled() {
                Log.d("AlloyDemo", "onCancelled")
            }

            override fun onDenied() {
                Log.d("AlloyDemo", "onDenied")
            }

            override fun onManualReview() {
                Log.d("AlloyDemo", "onManualReview")
            }

            override fun onSuccess() {
                Log.d("AlloyDemo", "onSuccess")
            }

            override fun journeyApplicationTokenCreated(token: String) {
                Log.d("AlloyDemo", "journeyApplicationTokenCreated: $token")
            }

            override fun gotError(error: String) {
                Log.d("AlloyDemo", "gotError: $error")
            }
        }