Enhanced Document Verification is exposed as a flow which performs the following high level steps:
Displays instructions to the user
Requests camera permissions (if not already granted)
Performs Document Capture
Performs Selfie Capture
useStrictMode defaults to false and will use Smile Smartselfie™ capture screens for selfie
If useStrictMode is set to true the selfie capture use Enhanced SmartSelfie™ capture
Submits the job to the Smile ID API
Delivers the result back to the caller
Consent Information
Some ID Types may require consent to be granted. In such cases the consent information would expect the below so this is completely optional and the SDK will default to false and consent time will be the time of execution
consentGrantedDate. // The date consent was granted defaults to the time of screen initialisation
personalDetailsConsentGranted // If the user has granted personal details consent defaults to false
contactInfoConsentGranted // If the user has granted contact information consent defaults to false
documentInfoConsentGranted // If the user has granted document information consent defaults to false
If the user has granted consent personalDetailsConsentGranted, contactInfoConsentGranted, documentInfoConsentGranted can all be set to true
Java has no named parameters so when using fragments instantiate the consent with the consent grant date in iSO format and all other values set to false.
import android.util.Log
import androidx.compose.runtime.Composable
import com.smileidentity.SmileID
import com.smileidentity.compose.SmartSelfieRegistration
import com.smileidentity.results.SmartSelfieResult
@Composable
fun EnhancedDocumentVerificationExample() {
// It will need to be provided as input depending on your use case
SmileID.EnhancedDocumentVerificationScreen(
countryCode = "GH",
consentInformation =
ConsentInformation(
consentGrantedDate = getCurrentIsoTimestamp(), // date in iso string format for when user granted consent
personalDetailsConsentGranted = false, // set true if user has agreed to personal details, will default to false
contactInfoConsentGranted = false, // set true if user has agreed to contact information, will default to false
documentInfoConsentGranted = false, // set true if user has agreed to document information, will default to false
),
useStrictMode = true, // true if you want to capture using enhanced SmartSelfie™ capture) { result ->
onResult = { result ->
when (result) {
is SmileIDResult.Success -> {
val resultData = result.data
Log.d("EnhancedDocumentVerification", "Success: $resultData")
// DocumentVerificationResult contains: captured documents, captured selfie,
// and job status response from the API
val (selfieFile, documentFrontFile, documentBackFile, jobStatusResponse) = resultData
}
is SmileIDResult.Error -> {
// There was an error (could be denied camera permissions, network errors, etc)
val throwable = result.throwable
Log.w("EnhancedDocumentVerification", "Failure: $it", throwable)
}
}
}
)
}
When using the Fragment approach, a convenience resultFromBundle static method is provided to help extract a typed object from the result Bundle.
import SwiftUI
import SmileID
struct HomeView: View, EnhancedDocumentVerificationResultDelegate {
@State private var presentDocumentVerification = false
var body: some View {
HStack(spacing: 15) {
Button(action: {
self.presentDocumentVerification.toggle()
}) {
Text("Enhanced Document Verification")
}
.sheet(isPresented: $presentDocumentVerification, content: {
SmileID.enhancedDocumentVerificationScreen(
consentInformation: ConsentInformation(
consentGrantedDate: "date consent granted", // date in iso string format for when user granted consent
personalDetailsConsentGranted: false, // set true if user has agreed to personal details, will default to false
contactInformationConsentGranted: false, // set true if user has agreed to contact information, will default to false
documentInformationConsentGranted: false // set true if user has agreed to document information, will default to false
),
countryCode: "GH",
useStrictMode: true, // true if you want to capture using enhanced SmartSelfie™ capture
delegate: self
)
})
}
}
func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
print("Successfully submitted Document Verification job")
}
func didError(error: Error) {
print("An error occurred - \(error.localizedDescription)")
}
}
let documentVerificationScreen = SmileID.enhancedDocumentVerificationScreen(...)
let controller = UIHostingController(rootView: documentVerificationScreen)
controller.modalPresentationStyle = .fullScreen
navigationController?.present(controller, animated: true)
Navigator.of(context).push( //Requires Navigator.of(context).push in order to load
MaterialPageRoute<void>(
builder: (BuildContext context) => Scaffold(
appBar: AppBar(title: const Text("SmileID Enhanced Document Verification")),
body: SmileIDEnhancedDocumentVerification(
countryCode: "GH",
documentType: "DRIVERS_LICENSE",
useStrictMode: true, // true if you want to capture using enhanced SmartSelfie™ capture (will invalidate the above)
consentGrantedDate : DateTime.now().toIso8601String(), // date in iso string format for when user granted consent
personalDetailsConsentGranted = false, // set true if user has agreed to personal details, will default to false
contactInformationConsentGranted = false, // set true if user has agreed to contact information, will default to false
documentInformationConsentGranted = false, // set true if user has agreed to document information, will default to false
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop(); //Return flow to your app
},
onError: (String errorMessage) {
// Your error handling logic
final snackBar = SnackBar(content: Text("Error: $errorMessage"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop(); //Return flow to your app
},
),
),
),
);
<SmileIDEnhancedDocumentVerificationView
allowAgentMode={false} // true if you need to use the secondary camera
showInstructions={true} // show instructions before capture
countryCode={'country code'}
documentType={'document type'}
captureBothSides={true}
allowGalleryUpload={false}
useStrictMode={true} // set to true for enhanced SmartSelfie™ capture
consentInformation={{ //required for enhanced document verification
consentGrantedDate = new Date().toISOString(), // date in iso string format for when user granted consent
personalDetailsConsentGranted: true, // set true if user has agreed to personal details, will default to false
contactInfoConsentGranted: true, // set true if user has agreed to contact information, will default to false
documentInfoConsentGranted: true, // set true if user has agreed to document information, will default to false
}}
style={{ width: '100%', height: '100%' }} //fill the entire view
onResult={(event) => {
}}
/>
On onResult, you will receive a JSON string following the structure:
{
"selfieFile": "<path to selfie file>",
"livenessFiles": "<path to liveness file>",
"documentFrontFile": "<path to document front file>",
"documentBackFile": "<path to document back file>",
"apiResponse": {
"code": "...",
"created_at": true | false,
"job_id": true | false,
"job_type": "",
"message": "",
"partner_id": "",
"partner_params": "",
"status": "",
"updated_at": "",
"user_id": ""
}
}
Arguments
country
A 2-letter country code (ISO 3166-1 alpha-2 compliant)
documentType
The type of document/ID that is to be captured. If omitted, the document type will be automatically determined
captureBothSides
Boolean indicating whether both sides of the ID card should be captured. When set to true, the user will still be presented with the option to skip capturing the back of the ID card. This value can be fetched by calling SmileID.api.getValidDocuments() and checking the hasBack property of a document
bypassSelfieCaptureWithFile
If this value is provided, then the user will not be asked to capture a selfie as part of this flow
userId
The user ID to associate with the job. Most often, this will correspond to a unique User ID within your own system. (If not provided at time of Registration, a random user ID will be generated. This field is required for Authentication)
jobId
The job ID to associate with the job. Most often, this will correspond to a unique Job ID within your own system. If not provided, a random job ID will be generated.
idAspectRatio
The aspect ratio of the ID to be captured. If not specified, the aspect ratio will attempt to be inferred from the device's camera.
showAttribution
Whether to show the Smile ID attribution or not on the Instructions screen
allowGalleryUpload
Whether the user should be allowed to upload their document photos from the Gallery instead of performing a live capture
showInstructions
Whether to deactivate capture screen's instructions
skipApiSubmission
Whether to capture images and not Submit to the SmileID api, this will return file paths which can be retrieved for later use.
extraPartnerParams
Custom values specific to partners passed as an immutable map
colorScheme
typography
onResult (Android)
Callback to be invoked when the job is complete. The result itself is a SmileIDResult which can either be a SmileIDResult.Success or SmileIDResult.Error
delegate(iOS)
This is the delegate object that is notified when there is a result from the DocumentVerification flow. This class has to conform to DocumentCaptureResultDelegate and implement the delegate methods
func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, jobStatusResponse: EnhancedDocumentVerificationJobStatusReponse) and func didError(error: Error).
Note: Recommend wrapping this in a component that can be navigated to and out of view due to a known issue with views displaying dialogs particularly on failure and the dialog keeps showing,