Document Verification

Perform a Document Verification

Document Verification is exposed as a flow which performs the following high level steps:

  1. Displays instructions to the user

  2. Requests camera permissions (if not already granted)

  3. Performs Document Capture

  4. Performs Selfie Capture

  5. Submits the job to the Smile ID API

  6. Delivers the result back to the caller

Usage

import SwiftUI
import SmileID

struct HomeView: View, DocumentVerificationResultDelegate {
    @State presentDocumentVerification = false
    var body: some View {
        HStack(spacing: 15) {
            Button(action: {self.presentDocumentVerification.toggle()}) {
                Text("Document Verification")
            }
            .sheet(isPresented: presentDocumentVerification, content: {
                SmileID.documentVerificationScreen(countryCode: "GH", delegate: self)
            })
        }
    }
    
    func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, jobStatusResponse: DocumentVerificationJobStatusResponse) {
        print("Successfully submitted Document Verification job")
    }

    func didError(error: Error) {
        print("An error occurred - \(error.localizedDescription)")
    }
}

To use the view in UIKit:

let documentVerificationScreen = SmileID.documentVerificationScreen(...)
let controller = UIHostingController(rootView: documentVerificationScreen)
controller.modalPresentationStyle = .fullScreen
navigationController?.present(controller, animated: true)

Arguments

countryCode

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.

delegate

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: DocumentVerificationJobStatusResponse) and func didError(error: Error).

Last updated