Manual Selfie
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.