Manual Selfie
Manual Selfie lets the user take the selfie by pressing a button.
Flow overviewFlowchart of this module's usage within the SDK flow. Expand to view it, click the chart to enlarge.
- S1, S2: set
AmaniDelegatewithsetDelegate(delegate:), then start the session withinitAmani(...)(optional SSL pinning before it). - S3:
selfie(),setType(type:), thenstart(); add the returned view (nil means: checkonError). - S4: upload the selfie. If the upload fails or the step is REJECTED, do not call
upload()again: the data is cleared after it. Open the selfie again (callstart()and add the new view, or show your kept view again), capture, then upload, up to your own max attempt. - S5, S6: follow the verdicts in
onStepModel/onProfileStatus, and callendSession()at the end. - Other modules may come before or after it, in the order your flow needs; the chart shows it alone to keep it simple.
You can access the Selfie module from the base Amani class as shown below.
caution
Before using this module please make sure you've initialized the SDK correctly.
let amaniSelfie = Amani.sharedInstance.selfie()
Starting the Selfie capture
The start method will return an instance of UIView.
self.selfieView = amaniSelfie.start() {[weak self] previewImage in
// after the process ends you can safely remove the selfieView from your view controller
DispatchQueue.main.async {
self.selfieView.removeFromSuperview()
}
// TODO: upload or show a confirm screen
}
// don't forget to add the selfie view to your view controller
DispatchQueue.main.async {
self.view.addSubview(self.selfieView)
}
Upload
After completing the capture proccess you can call the upload as shown below.
amaniSelfie.upload(location: nil) {[weak self] uploadSuccess in
if (uploadSuccess != nil) {
// uploadSuccess is a boolean variable
// TODO: handle the upload state
}
}
Getting the documentId after the upload
Starting with AmaniSDK 3.7.6, upload also accepts a closure with two parameters. The second parameter is the documentId of the document that the upload created.
amaniSelfie.upload(location: nil) { isSuccess, documentId in
if isSuccess == true, let documentId {
// Upload succeeded, store the documentId
print("Upload completed, documentId: \(documentId)")
} else {
// Upload failed, documentId is nil
}
}
note
The closure with only isSuccess still works. You don't need to change your existing integration.