Callbacks
We provide you with the following callbacks:
Tip
Callbacks are optional. Use them if you feel they will be helpful.
Status updates notification
Use the onStatusDidChange
callback to get notified about the stages of the verification process.
The callback takes two parameters. The first one sdk
is the SDK instance, and the last one prevStatus
lets you know the previous value of the status
.
Following this, you are able to examine the sdk.status
enum in order to determine the current SDK status.
sdk.onStatusDidChange { (sdk, prevStatus) in
print("onStatusDidChange: [\(sdk.description(for: prevStatus))] -> [\(sdk.description(for: sdk.status))]")
switch sdk.status {
case .ready:
// Technically .ready couldn't ever be passed here, since the callback has been set after `status` became .ready
break
case .failed:
print("failReason: [\(sdk.description(for: sdk.failReason))] - \(sdk.verboseStatus)")
case .initial:
print("No verification steps are passed yet")
case .incomplete:
print("Some but not all of the verification steps have been passed over")
case .pending:
print("Verification is pending")
case .temporarilyDeclined:
print("Applicant has been temporarily declined")
case .finallyRejected:
print("Applicant has been finally rejected")
case .approved:
print("Applicant has been approved")
case .actionCompleted:
print("Face Auth action has been completed")
}
}
Events notification
Subscribing to the onEvent
callback allows you to be aware of the events happening along the processing.
Events are passed into the callback as instances of a class inherited from the base SNSEvent
class, this way each event has its eventType
and some parameters packed into payload
dictionary.
Depending on your needs, you can get event parameters either by examining the payload
directly or by casting the given event instance to a specific SNSEvent*
class according to its type.
sdk.onEvent { (sdk, event) in
switch event.eventType {
case .applicantLoaded:
if let event = event as? SNSEventApplicantLoaded {
print("onEvent: Applicant [\(event.applicantId)] has been loaded")
}
case .stepInitiated:
if let event = event as? SNSEventStepInitiated {
print("onEvent: Step \(event.idDocSetType) has been initiated")
}
case .stepCompleted:
if let event = event as? SNSEventStepCompleted {
print("onEvent: Step \(event.idDocSetType) has been \(event.isCancelled ? "cancelled" : "fulfilled")")
}
case .analytics:
if let event = event as? SNSEventAnalytics {
print("onEvent: Analytics event [\(event.eventName)] has occured with payload=\(event.eventPayload ?? [:])")
}
@unknown default:
print("onEvent: eventType=\(event.description(for: event.eventType)) payload=\(event.payload)")
}
}
Dismiss notification
An optional way to be notified when mainVC
is dismissed.
sdk.onDidDismiss { (sdk) in
print("onDidDismiss: sdk has been dismissed with status [\(sdk.description(for: sdk.status))]")
}
Updated 7 months ago