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:
let consoleLogging = ConsoleLoggingImpl()
idenfyController.setIdenfyLoggingHandler(idenfyLoggingHandler: IdenfyLoggingHandlerUseCaseImpl(consoleLogging))
class ConsoleLoggingImpl {
func log(event: String, message: String, token _: String) {
print("SDKLog", event, " - ", message)
}
}
import iDenfySDK
class IdenfyLoggingHandlerUseCaseImpl: IdenfyLoggingHandlerUseCase {
private var consoleLogging: ConsoleLoggingImpl!
init(_ consoleLogging: ConsoleLoggingImpl) {
self.consoleLogging = consoleLogging
}
func logEvent(event: String, message: String, token: String) {
#if DEBUG
consoleLogging.log(event: event, message: message, token: token)
#endif
}
}
User events webhooks
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.
- Swift
- Objective-C
import iDenfySDK
@objc public class IdenfyUserFlowCallbacksHandler: NSObject, IdenfyUserFlowHandler {
public func onPhotoUploaded(photo: String, step: String) {
print("IdenfyUserFlowHandler - onPhotoUploaded \(step)")
}
public func onDocumentSelected(documentType: String) {
print("IdenfyUserFlowHandler - onDocumentSelected \(documentType)")
}
public func onCountrySelected(issuingCountryCode: String) {
print("IdenfyUserFlowHandler - onCountrySelected \(issuingCountryCode)")
}
public func onProcessingStarted(processingStarted: Bool) {
print("IdenfyUserFlowHandler - onProcessingStarted \(processingStarted)")
}
}
/// IdenfyUserFlowCallbacksHandler.h
#import <Foundation/Foundation.h>
#import <iDenfySDK/iDenfySDK-Swift.h>
@interface IdenfyUserFlowCallbacksHandler: NSObject <IdenfyUserFlowHandler>
@end
/// IdenfyUserFlowCallbacksHandler.m
#import "IdenfyUserFlowCallbacksHandler.h"
@implementation IdenfyUserFlowCallbacksHandler
- (void)onCountrySelectedWithIssuingCountryCode:(NSString * _Nonnull)issuingCountryCode {
NSLog(@"IdenfyUserFlowHandler - onCountrySelected %@", issuingCountryCode);
}
- (void)onDocumentSelectedWithDocumentType:(NSString * _Nonnull)documentType {
NSLog(@"IdenfyUserFlowHandler - onDocumentSelected %@", documentType);
}
- (void)onPhotoUploadedWithPhoto:(NSString * _Nonnull)photo step:(NSString * _Nonnull)step {
NSLog(@"IdenfyUserFlowHandler - onPhotoUploaded %@", step);
}
- (void)onProcessingStartedWithProcessingStarted:(BOOL)processingStarted {
NSLog(@"IdenfyUserFlowHandler - onProcessingStarted %id", processingStarted);
}
@end
Set the idenfyUserFlowCallbacksHandler
Set the idenfyUserFlowCallbacksHandler in the IdenfyController class:
- Swift
- Objective-C
...
idenfyController.setIdenfyUserFlowCallbacksHandler(idenfyUserFlowHandler: IdenfyUserFlowCallbacksHandler())
...
...
IdenfyUserFlowCallbacksHandler *idenfyUserFlowCallbackHandler = [[IdenfyUserFlowCallbacksHandler alloc] init];
[idenfyController setIdenfyUserFlowCallbacksHandlerWithIdenfyUserFlowHandler:idenfyUserFlowCallbackHandler];
...