Source Code
class MainActivity : AppCompatActivity() {
private lateinit var sdk: CafFaceLivenessSDK
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.toolbar)
setupCafFaceLiveness()
binding.startLivenessButton.setOnClickListener { view ->
sdk.startSDK(
this,
"mobileToken",
"personId"
)
}
}
private fun setupCafFaceLiveness() {
sdk = CafFaceLivenessSDK.CafBuilder()
.setStage(CafStage.PROD)
.setScreenCaptureEnabled(true)
.setLoadingScreen(true)
.setListener(
setupCafLivenessListener()
).build()
}
private fun setupCafLivenessListener() = object : CafLivenessListener {
override fun onCancel() {
println("onCancel")
}
override fun onError(sdkFailure: CafLivenessError) {
println("onError: ${sdkFailure.message}")
}
override fun onLoaded() {
// This event will only be called when the loading screen isn't enabled
println("onLoaded")
}
override fun onLoading() {
// This event will only be called when the loading screen isn't enabled
println("onLoading")
}
override fun onSuccess(livenessResult: CafLivenessResult) {
println("onSuccess: ${livenessResult.signedResponse}")
}
}
}
Last updated