Skip to main content

Bio Login with Backend V1

When setting up Amani for Bio Login, you can use any module under the Selfie Module sections, you need to give the UploadSource parameter in the init method as BIOLOGIN, or you can use the setUploadSource function after initing the Amani SDK.

Flow overviewFlowchart of this module's usage within the SDK flow. Expand to view it, click the chart to enlarge.

Bio Login V1 flow

  • B1: set AmaniDelegate with setDelegate(delegate:).
  • B2: start the session with initAmani(..., uploadSource: .BIOLOGIN, ...), or call setUploadSource(uploadSource: .BIOLOGIN) after it.
  • B3: capture with a selfie module; add the returned view (nil means: check onError).
  • B4: upload the selfie; the verdict arrives later in AmaniDelegate. If the upload fails, do not call upload() again: the data is cleared after it. Open the selfie again (call start() and add the new view, or show your kept view again), capture, then upload, up to your own max attempt.
  • B5: after the verdict has arrived, set the upload source back with setUploadSource(uploadSource: .KYC).

The usage is as follows:

let amani:Amani = Amani.sharedInstance

amani.initAmani(
server: "<YOUR_SERVER_URL>",
token: "<YOUR_TOKEN>",
apiVersion: .v2
) { customerModel, error in
//If you wish you can set upload source parameter on above initAmani func or you can set directly setUploadSource function.
if let error = error {
print("Amani initAmani failed: \(error.localizedDescription)")
return
}

DispatchQueue.main.async {
do {
// Here you can set directly enum raw value or you can use string value.
amani.setUploadSource(uploadSource: .BIOLOGIN) // "bio_login"

let selfie = amani.selfie()

let view = try selfie.start { previewImage in
print("Amani Selfie captured. previewImage=\(previewImage != nil)")

selfie.upload { isSuccess in
if isSuccess == true {
print("Amani Upload success")
} else {
print("Amani Upload failed")
}
}
}

if let v = view {
print("Amani Selfie Module start func returned a UIView. Add it to your hierarchy.")
} else {
print("Amani Selfie Module start func returned nil view")
}

} catch {
print("Amani Selfie start error: \(error.localizedDescription)")
}
}
}