Skip to main content

Launching the SDK

1. Generating Token

You need to generate a verification token before launching the SDK. This token is typically obtained from your backend API using collected user information (ID number, purpose, etc.).

// Example: Generate token from your API
private suspend fun generateToken(idNumber: String, purpose: String?): String {
// Call your API to generate verification token
// Return the token string
return "your-generated-token"
}
info

2. Launch

Use the Activity Result Contract to launch the fingerprint authentication flow:

import com.metric.fingerprint.ui.contract.*
import androidx.activity.result.contract.ActivityResultContracts

class MainActivity : ComponentActivity() {

private val fingerprintLauncher = registerForActivityResult(
FingerprintAuthContract()
) { result ->
when (result) {
is FingerprintAuthResult.Success -> {
// Authentication successful
val customerName = result.name
val customerSuid = result.suid
// Handle success
}
is FingerprintAuthResult.Error -> {
// Authentication failed
val message = result.message
// Handle error
}
is FingerprintAuthResult.Cancelled -> {
// User cancelled
// Handle cancellation
}
}
}

fun launchFingerprintAuth(token: String) {
fingerprintLauncher.launch(
FingerprintAuthRequest(token = token)
)
}
}