Logging & webhooks
Logging
The SDK provides a possibility to log users and SDK common actions (lifecycles events, navigation, camera changes). This can be useful for understanding specific scenarios or troubleshooting potential issues. To enable logging you need to provide your implementation of the IdenfyLoggingHandlerUseCase class. You can implement it like this:
Kotlin
val consoleLogging = ConsoleLoggingImpl()
IdenfyController.getInstance().idenfyLoggingHandler = IdenfyLoggingHandlerUseCaseImpl(consoleLogging)
class ConsoleLoggingImpl {
fun log(event: String, message: String, token: String) {
Log.d("fromIdenfySDK-$event", message)
}
}
class IdenfyLoggingHandlerUseCaseImpl(private var consoleLoggingImpl: ConsoleLoggingImpl):IdenfyLoggingHandlerUseCase {
override fun logEvent(event: String, message: String, token: String) {
consoleLoggingImpl.log(event, message, token)
}
}
As you can see we made it very flexible, therefore you only need to provide a concrete implementation of the IdenfyLoggingHandlerUseCase interface. If you also want to see the Okhttp requests/responses and payload in the Logcat, you should initialize iDenfySDK with IdenfySDKLoggingEnum.FULL, like this:
val idenfySettingsV2 = IdenfySettingsV2.IdenfyBuilderV2()
.withAuthToken(authToken)
.withLogging(IdenfySDKLoggingEnum.FULL)
.build()
User events webhooks (optional)
SDK provides webhooks about events occurring throughout the verification process. Results will be delivered while the verification process is occurring and the application is presenting views of the SDK.
Declare a class for receiving events
Declare a class that implements IdenfyUserFlowHandler to call your backend service, log events, or apply changes.
class IdenfyUserFlowCallbacksHandler : IdenfyUserFlowHandler {
/**
* @param documentType Selected document type
*/
override fun onDocumentSelected(documentType: String) {
Log.d("onDocumentSelected", documentType)
}
/**
* @param issuingCountryCode Selected issuingCountryCode
*/
override fun onCountrySelected(issuingCountryCode: String) {
Log.d("onCountrySelected", issuingCountryCode)
}
/**
* @param photosUploaded indicated that photos have been uploaded
*/
override fun onPhotosUploaded(photosUploaded: Boolean) {
Log.d("onPhotosUploaded", photosUploaded.toString())
}
/**
* @param processingStarted indicates that processing has started
*/
override fun onProcessingStarted(processingStarted: Boolean) {
Log.d("onProcessingStarted", processingStarted.toString())
}
}
Configure application class
Set IdenfyUserFlowController to reference idenfyUserFlowCallbacksHandler in the application class.
class IdenfyApplication : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
val idenfyUserFlowCallbacksHandler =
IdenfyUserFlowCallbacksHandler()
IdenfyUserFlowController.setIdenfyUserFlowHandler(idenfyUserFlowCallbacksHandler)
}
}
it is required to set webhooks handler in the application class to ensure that listener will be set again after the application process has stopped.