Auto Selfie
You can access the AutoSelfie
module from the base Amani
class as shown below.
Before using this module please make sure you've initialized the SDK correctly.
let amaniAutoSelfie = Amani.sharedInstance.autoSelfie()
Configuration
Configuring the messages
These are the messages that you can configure. You can use this table with a
dictionary in [infoMessages: String]
type.
Key | Type | Description |
---|---|---|
faceIsOk | string | Shows before capturing the selfie |
notInArea | string | Shows when the user's face is not in the area |
faceTooSmall | string | Shows when the user's face is too far |
faceTooBig | string | Shows when the user's face is too close |
completed | string | Shows when the process is completed |
var infoMessages: [infoState: String] = [
.faceIsOk: "Please hold stable",
.notInArea: "Please align your face with the area",
.faceTooSmall:"Your face is too far",
.faceTooBig: "Your face is too close",
.completed: "All done!",
]
After creating the dictionary, you can call the setInfoMessages
function with it.
amaniAutoSelfie.setInfoMessages(infoMessages: infoMessages)
Configuring the screen
As much as you can change the info messages, you can also change the on screen and also the count timer. These are the keys that we have for configuration.
With the keys below you can create a dictionary with type of [configState: String]
Key | Type | Description |
---|---|---|
appBackgroundColor | String | Hex color with no hash sign (#) |
appFontColor | String | Hex color with no hash sign (#) |
primaryButtonBackgroundColor | String | Hex color with no hash sign (#) |
ovalBorderSuccessColor | String | Hex color with no hash sign (#) |
ovalBorderColor | String | Hex color with no has sign (#) |
countTimer | String | Number wrapped in a string |
var screenConfig: [configState:String] = [
.appBackgroundColor: "000000",
.appFontColor: "ffffff",
.primaryButtonBackgroundColor: "ffffff",
.ovalBorderSuccessColor: "00ff00",
.ovalBorderColor: "ffffff",
.countTimer:"3"
After creating the dictionary you can call setScreenConfig
with it.
amaniAutoSelfie.setScreenConfig(screenConfig: screenConfig)
Starting the Auto Selfie Capture
The start
method will return an instance of UIView
self.autoSelfieView = amaniAutoSelfie.start() {[weak self] previewImage in
// after the process ends you can safely remove the autoSelfieView from your view controller
DispatchQueue.main.async {
self?.autoSelfieView.removeFromSuperView()
}
// TODO: upload or show a confirm screen
}
// don't forget to add the auto selfie view to your view controller
DispatchQueue.main.async {
self.view.addSubView(self.autoSelfieView)
}
Upload
After completing the capture process you can call the upload as shown below.
amaniAutoSelfie.upload(location: nil) {[weak self] uploadSuccess in
if (uploadSuccess != nil) {
// uploadSuccess is a boolean variable
// TODO: handle the upload state
}
}