SmartSelfie™ Enrollment and Authentication

Perform a SmartSelfie Enrollment or Authentication job

SmartSelfie™ Authentication 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. Captures and saves Liveness and Selfie images

  4. Submits the job to the Smile ID API

  5. Polls for a job response

  6. Delivers the result back to the caller via a delegate

Usage

import SwiftUI
import SmileID

struct HomeView: View, SmartSelfieResultDelegate {
@State presentAuth = false
@State presentEnroll = false

    var body: some View {
        HStack(spacing: 15) {
            Button(action: {self.presentEnroll.toggle()}) {
                Text("SmartSelfie™ Enrollment")
            }
            .sheet(isPresented: $presentEnroll, content: {
                SmileID.smartSelfieEnrollmentScreen(userId: "userID", delegate: self)
            })
            
            Button(action: {self.presentAuth.toggle()}) {
                Text("SmartSelfie™ Authentication")
            }
            .sheet(isPresented: $presentEnroll, content: {
                SmileID.smartSelfieAuthenticationScreen(userId: "userID", delegate: self)
            })
        }
    }
    
    func didSucceed(selfieImage: Data, livenessImages: [Data], jobStatusResponse: SmartSelfieJobStatusResponse) {
        print("Successfully submitted SmartSelfie job")
    }

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

To use the view in UIKit:

let smartSelfieEnrollmentScreen = SmileID.smartSelfieEnrollmentScreen(...)
let uiKitController = UIHostingController(rootView: smartSelfieEnrollmentScreen)
smartSelfieScreen.modalPresentationStyle = .fullScreen
navigationController?.present(uiKitController, animated: true)

If you are registering a user for the first time, you should use SmileID.smartSelfieEnrollmentScreen

If you are authenticating a previously registered user, you should use SmileID.smartSelfieAuthenticationScreen

Arguments

userId

The user ID to associate with the SmartSelfie™ Registration. 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 SmartSelfie™ Registration. Most often, this will correspond to a unique Job ID within your own system. If not provided, a random job ID will be generated.

allowAgentMode

Whether to allow Agent Mode or not. If allowed, a switch will be displayed allowing toggling between the back camera and front camera. If not allowed, only the front camera will be used.

showAttribution

Whether to show the Smile ID attribution or not on the Instructions screen

delegate

This is the delegate object that is notifed when there is a result from the SmartSelfie™ flow. This class has to conform to SmartSelfieResultDelegate and implement the delegate methods func didSucceed(selfieImage: Data, livenessImages: [Data], jobStatusResponse: JobStatusReponse) and func didError(error: Error)

Last updated