Usage (Kotlin)
Under Development: This SDK is currently in development. Documentation and API may change. For production use, please contact our team.
Overview
The vouch Android SDK provides a UI flow for initiating and managing verification within your app. It uses the Activity Result APIs, so you can launch the flow from a ComponentActivity or Fragment and handle the result in a single callback.
Initialization
Create a single VouchSdk instance in your Activity or Fragment and keep it alive for the lifetime of that component.
Recommended initialization pattern:
import androidx.activity.ComponentActivity
import com.vlayer.vouch.sdk.VouchSdk
class MainActivity : ComponentActivity() {
private val vouchSdk = VouchSdk(this)
}Important: Keep the SDK instance alive for the entire lifecycle of your Activity or Fragment. Creating multiple instances may lead to unexpected behavior.
Requesting a Verification
To start a verification flow, build a ProveConfig and call vouchSdk.prove. The SDK will launch its UI and return a NotarizationRequestSdkResult when finished.
Basic usage example:
import com.vlayer.vouch.sdk.NotarizationRequestSdkResult
import com.vlayer.vouch.sdk.ProveConfig
import com.vlayer.vouch.sdk.VouchSdk
class MainActivity : ComponentActivity() {
private val vouchSdk = VouchSdk(this)
private fun startProving() {
val inputs = mapOf<String, String>(
"inputParamName" to "inputParamValue"
)
val proveConfig = ProveConfig(
datasourceId = "DATA_SOURCE_ID",
customerId = "CUSTOMER_ID",
inputs = inputs,
webhookUrl = "WEBHOOK_URL"
)
vouchSdk.prove(
context = this,
proveConfig = proveConfig,
callback = ::handleNotarizationResult
)
}
private fun handleNotarizationResult(result: NotarizationRequestSdkResult) {
when (result) {
is NotarizationRequestSdkResult.Success -> {
val requestId = result.requestId
// Handle success
}
is NotarizationRequestSdkResult.Failure -> {
val requestId = result.requestId
val message = result.message
// Handle failure
}
is NotarizationRequestSdkResult.Canceled -> {
val requestId = result.requestId
// Handle cancellation
}
}
}
}Parameters
The ProveConfig requires your customerId, datasourceId, and webhookUrl.
For detailed documentation on datasourceId, webhookUrl, and inputs, see the Vouch URL Parameters section.
Note: In the Android SDK, inputs is passed as a Map<String, String> and is serialized internally by the SDK.
Result Handling
The callback receives a NotarizationRequestSdkResult:
Success: verification completed; containsrequestIdFailure: verification failed; containsrequestId(nullable) andmessage(nullable)Canceled: user canceled; containsrequestId(nullable)
Best Practice: Always handle all result types and log the requestId for debugging and user support.