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
Key | Type | Required | Description |
---|---|---|---|
apiKey | string | required | This is your Alloy SDK key. It can be found in the settings section of your Alloy dashboard |
journeyToken | string | required | Your Journey Token can be grabbed from the Journey page on your Alloy dashboard |
JourneyApplicationToken | string | optional, required when using step-up | Specific application of a Journey |
isSingleEntity | boolean | optional | Use this parameter if you want to send each entity their own portion of the step up process |
entityToken | string | optional | Required if isSingleEntity is true. |
externalEntityId | string | optional | |
production | boolean | required | Indicates if you are hitting sandbox or prod API endpoints |
color | json | optional | |
customStyle | json | optional |
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
Key | Type | Required | Description |
---|---|---|---|
activity | outer scope reference | required | This is the outer scope reference of the activity the SDK is being used in |
settings | class | required | This 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")
}
}
Updated 9 months ago