LogoLogo
  • Welcome!
  • GETTING STARTED
    • Signing Up
    • Choose a Product
    • Choose an Integration Option
    • Run Your First Test Job
    • Complete Your KYC
    • Fund Your Wallet
    • Go Live!
    • Pricing
  • SUPPORTED ID TYPES & DOCUMENTS
    • For Individuals (KYC)
      • Using ID Number
        • Supported Countries
          • Côte d'Ivoire
            • National ID (without Photo)
            • Resident ID (without Photo)
          • Ghana
            • Ghana Card
            • Passport
            • Voter's ID
          • Kenya
            • Alien Card
            • KRA Pin
            • National ID
            • National ID (without Photo)
            • Passport
            • Tax Information
          • Nigeria
            • Bank Account
            • BVN
            • NIN V2
            • NIN Slip Verification
            • V_NIN (Virtual NIN)
            • Phone Number
            • Voter's ID
          • South Africa
            • National ID
            • National ID (without Photo)
            • Phone Number
          • Uganda
            • National ID (without Photo)
            • Basic KYC in Uganda
          • Zambia
            • Bank Account
            • TPIN
          • Zimbabwe
            • National ID (without Photo)
        • Test Data
          • Customising Sandbox Test Data
        • ID Number Regex
        • Visual Samples of Supported ID Types
      • Using Document Image
        • Continents
          • Africa
          • Asia and the Middle East
          • Europe
          • North America
          • Oceania
          • South America
    • For Businesses (KYB)
      • Supported Countries
        • Nigeria
          • Business Registration
          • Tax Information
        • Kenya
          • Business Registration
        • South Africa
          • Business Registration
      • ID Number Regex
  • PRODUCTS
    • For Individuals (KYC)
      • AML Check
        • AML News Media
      • Basic KYC
      • Biometric KYC
      • Digital Address Verification
      • Document Verification
        • Document Verification
        • Enhanced Document Verification
      • Electronic Signature
      • Enhanced KYC
      • Phone Number Verification
      • SmartSelfie™ Authentication
      • SmartSelfie™ Compare
      • Smile Secure
    • For Businesses (KYB)
      • Business Verification
  • Integration Options
    • Mobile
      • Getting Started
      • Products
        • Biometric KYC
        • BVN Consent
        • Document Verification
        • Enhanced Document Verification
        • Enhanced KYC
        • SmartSelfie™ Enrollment and Authentication
        • Enhanced SmartSelfie™ Enrollment And Authentication
      • Customization
        • UI Components
      • Offline Mode
      • Release Notes
        • Android Release Notes
        • iOS Release Notes
        • Flutter Release Notes
        • React Native Release Notes
    • No-Code
      • Smile Links
        • Link FAQs
        • Rest API
    • Server to Server
      • Ruby
        • Installation
        • Signature
        • Products
          • Basic KYC
          • Enhanced KYC
          • Biometric KYC
          • Document Verification
          • SmartSelfie™ Authentication
          • KYB - Business Verification
          • AML Check
        • Generate Token for Web Integration
        • Utilities
      • Python
        • Installation
        • Signature
        • Products
          • Basic KYC
          • Enhanced KYC
          • Biometric KYC
          • Document Verification
          • SmartSelfie™ Authentication
          • Business Verification
        • Generate Token for Web Integration
        • Utilities
      • Java
        • Release Notes
        • Installation
        • Signature
        • Products
          • Basic KYC
          • Enhanced KYC
          • Biometric KYC
          • Document Verification
          • SmartSelfie™ Authentication
        • Generate Token for Web Integration
        • Utilities
      • Node.js
        • Installation
        • Signature
        • Products
          • Basic KYC
          • Enhanced KYC
          • Biometric KYC
          • Document Verification
          • Enhanced Document Verification
          • SmartSelfie™ Authentication
          • Business Verification
        • Generate Token for Web Integration
        • Utilities
      • PHP
        • Installation
        • Signature
        • Products
          • Basic KYC
          • Enhanced KYC
          • Biometric KYC
          • Document Verification
          • SmartSelfie™ Authentication
        • Generate Token for Web Integration
        • Utilities
    • Rest API
      • Signing your API Request
        • Using Signature
      • Products
      • Postman Collection
      • Utilities
    • Web / Mobile Web
      • Web Integration
        • Installation
        • Usage
        • End User Consent
        • Support
      • Javascript SDK
        • Installation
        • Usage
        • Migration
        • Deprecated Version
          • Installation
          • Usage
          • Notes
          • Support
  • FURTHER READING
    • FAQs
      • What are your support hours?
      • How do I set up a callback?
      • How to re-enroll, deactivate or delete a user?
      • Add or remove team members
      • What are top-level keys?
      • What are partner_params?
      • How do job types map to the new product names?
      • Is there an API I can use to monitor my wallet balance?
      • Is there an API I can query to check the availability status of an ID type?
      • How do I integrate Smile ID in other countries or query other ID types?
      • What are the image types I can upload to Smile ID?
      • Why aren't Kenyan IDs returning images for some IDs queried?
      • Why are some of my bank verification requests returning 'ID authority unavailable'?
      • How can I look up a specific user's data?
      • Selfie best-practices
      • Document capture best-practices
      • What happens under the hood?
      • Guide to the user consent screen
      • What is code 2302?
      • Using the Demo App and Scanning QR codes
    • Job status
    • KYC receipts
    • Result codes
      • Error codes
    • Securing your account with two-factor authentication (2FA)
    • Security Overview
    • Troubleshooting
      • Troubleshooting error 2204 & 2205 - "You're not authorized to do that"
      • Why is my Web API job taking so long?
      • Image capture issues on web client
Powered by GitBook
On this page

Was this helpful?

  1. Integration Options
  2. Mobile
  3. Products

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. Delivers the result back to the caller

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

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

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 SmartSelfieRegistrationExample() {
    SmileID.SmartSelfieEnrollment { result ->
        when (result) {
            is SmileIDResult.Success -> {
                val resultData = result.data
                Log.d("SmartSelfieEnrollment", "Success: $resultData")
                // SmartSelfieResult.Success contains: captured selfie file, captured liveness
                // files, and latest job status response from the API
                val (selfieFile, livenessFiles, jobStatusResponse) = resultData
            }

            is SmileIDResult.Error -> {
                // There was an error (could be denied camera permissions, network errors, etc)
                val throwable = result.throwable
                Log.w("SmartSelfieEnrollment", "Failure: $it", throwable)
            }
        }
    }
}

If you are registering a user for the first time, you should use SmartSelfieEnrollmentFragment

If you are authenticating a previously registered user, you should use SmartSelfieAuthenticationFragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.FragmentActivity
import com.smileidentity.fragment.SmartSelfieEnrollmentFragment


class JavaActivity : FragmentActivity() {
    private fun doSmartSelfieEnrollment() {
        val smartSelfieFragment = SmartSelfieEnrollmentFragment.newInstance()
        supportFragmentManager.setFragmentResultListener(
            SmartSelfieEnrollmentFragment.KEY_REQUEST,
            this,
        ) { _: String?, result: Bundle? ->
            val smartSelfieResult = SmartSelfieEnrollmentFragment.resultFromBundle(result!!)
            Log.v("SmartSelfieEnrollment", "Result: $smartSelfieResult")
            when (smartSelfieResult) {
                is SmileIDResult.Success -> {
                    val (selfieFile, livenessFiles, jobStatusResponse) = smartSelfieResult.data
                    // Note: Although the API submission is successful, the job status response
                    // may indicate that the job is still in progress or failed. You should
                    // check the job status response to determine the final status of the job.
                    if (jobStatusResponse.jobSuccess) {
                        Log.v("SmartSelfieEnrollment", "Job Success")
                    } else if (!jobStatusResponse.jobComplete) {
                        Log.v("SmartSelfieEnrollment", "Job Not Complete")
                    } else {
                        Log.v("SmartSelfieEnrollment", "Job Failed")
                    }
                }
                is SmileIDResult.Error -> {
                    val throwable = smartSelfieResult.throwable
                    Log.v("SmartSelfieEnrollment", "Error: " + throwable.message)
                }
            }
            supportFragmentManager
                .beginTransaction()
                .remove(smartSelfieFragment)
                .commit()
        }
        supportFragmentManager
            .beginTransaction()
            .replace(android.R.id.content, smartSelfieFragment)
            .commit()
    }
}

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, 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)")
    }
}
let smartSelfieEnrollmentScreen = SmileID.smartSelfieEnrollmentScreen(...)
let uiKitController = UIHostingController(rootView: smartSelfieEnrollmentScreen)
smartSelfieScreen.modalPresentationStyle = .fullScreen
navigationController?.present(uiKitController, 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 Selfie Enrollment")),
            body: SmileIDSmartSelfieEnrollment(
                userId: "random-user-id/generated-user-id",
                // There are more parameters -- they correspond 1:1 with the native SDK parameters
                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
                }
            ),
        ),
    ),
);

If you are authenticating a previously registered user, you should use SmileIDSmartSelfieAuthentication Flutter widget

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 Selfie Authentication")),
            body: SmileIDSmartSelfieAuthentication(
                userId: "random-user-id/generated-user-id",
                // There are more parameters -- they correspond 1:1 with the native SDK parameters
                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
                }
            ),
        ),
    ),
);
 <SmileIDSmartSelfieEnrollmentView
  userId: "random-user-id/generated-user-id",
  style={{ width: '100%', height: '100%' }} //fill the entire view
  onResult={(event) => {
    setResult(event.nativeEvent.result);
  }}
  />

If you are authenticating an existing user you should use SmileIDSmartSelfieAuthenticationView

 <SmileIDSmartSelfieAuthenticationView
  userId: "random-user-id/generated-user-id",
  style={{ width: '100%', height: '100%' }} //fill the entire view
  onResult={(event) => {
    setResult(event.nativeEvent.result);
  }}
  />

React Native component

On onResult, you will receive a JSON string following the structure:

{
  "selfieFile":  "<path to selfie file>",
  "livenessFiles": "<path to liveness files>",
  "apiResponse": {
    "code": "...",
    "created_at": true | false,
    "job_id":  true | false,
    "job_type": "",
    "message": "",
    "partner_id": "",
    "partner_params": "",
    "status": "",
    "updated_at": "",
    "user_id": "",
  }
}

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.

allowNewEnroll

Allows a partner to enroll the same user id again

showAttribution

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

showInstructions

Whether to deactivate capture screen's instructions for SmartSelfie.

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 SmartSelfie™ Registration 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 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)

PreviousEnhanced KYCNextEnhanced SmartSelfie™ Enrollment And Authentication

Last updated 3 months ago

Was this helpful?

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,

See

See

⚠️
Theming
Theming