Enhanced SmartSelfie™ Enrollment And Authentication
Perform an Enhanced SmartSelfie™ Verification
Enhanced SmartSelfie™ provides an advanced liveness tool for capturing your users.
Enhanced SmartSelfie™ Enrollment and Authentication
SmartSelfie™ Authentication is exposed as a flow which performs the following high level steps:
Displays instructions to the user
Requests camera permissions (if not already granted)
Captures and saves Liveness and Selfie images
Submits the job to the Smile ID API
Delivers the result back to the caller
If you are registering a user for the first time, you should use SmileID.SmartSelfieEnrollmentEnhanced
SmileID.SmartSelfieEnrollmentEnhanced(
userId = "user-id-here"
) { result ->
when(result) {
is SmileIDResult.Error -> {
// There was an error (could be denied camera permissions, network errors, etc)
Timber.e(result.throwable)
}
is SmileIDResult.Success -> {
val (selfieFile, livenessFiles, apiResponse) = result.data
// use the response here
}
}
}
If you are authenticating a previously registered user, you should use SmileID.SmartSelfieAuthenticationEnhanced
SmileID.SmartSelfieAuthenticationEnhanced(
userId = "user-id-here"
) { result ->
when(result) {
is SmileIDResult.Error -> {
// There was an error (could be denied camera permissions, network errors, etc)
Timber.e(result.throwable)
}
is SmileIDResult.Success -> {
val (selfieFile, livenessFiles, apiResponse) = result.data
// use the response here
}
}
}
import SwiftUI
import SmileID
struct HomeView: View, SmartSelfieResultDelegate {
@State var presentAuth = false
@State var presentEnroll = false
var body: some View {
VStack{
SmileID.smartSelfieEnrollmentScreenEnhanced(userId: "userID", delegate: self)
}
}
func didSucceed(selfieImage: URL, livenessImages: [URL],
apiResponse: SmartSelfieResponse?) {
print("Submitted Job Successfully")
}
func didError(error: Error) {
print("An error occured - \(error.localizedDescription)")
}
}
If you are authenticating an existing user you should use the smartSelfieAuthenticationScreenEnhanced
widget
struct HomeView: View, SmartSelfieResultDelegate {
@State var presentAuth = false
@State var presentEnroll = false
var body: some View {
VStack{
SmileID.smartSelfieAuthenticationScreenEnhanced(userId: "userID", delegate: self)
}
}
func didSucceed(selfieImage: URL, livenessImages: [URL],
apiResponse: SmartSelfieResponse?) {
print("Submitted Job Successfully")
}
func didError(error: Error) {
print("An error occured - \(error.localizedDescription)")
}
}
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: SmileIDSmartSelfieEnrollmentEnhanced(
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 SmileIDSmartSelfieAuthenticationEnhanced
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: SmileIDSmartSelfieAuthenticationEnhanced(
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
}
),
),
),
);
<SmileIDSmartSelfieEnrollmentEnhancedView
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 SmileIDSmartSelfieAuthenticationEnhancedView widget
<SmileIDSmartSelfieAuthenticationEnhancedView
userId: "random-user-id/generated-user-id",
style={{ width: '100%', height: '100%' }} //fill the entire view
onResult={(event) => {
setResult(event.nativeEvent.result);
}}
/>
Before using the widgets, define a SmartSelfieParams
object to configure the SmartSelfie™ flow:
import { SmartSelfieParams } from 'react-native-expo';
const smartSelfieParams: SmartSelfieParams = {
// userId: 'user123', // Optional user ID
// jobId: 'job456', // Optional job ID
allowNewEnroll: false,
allowAgentMode: true,
showAttribution: true,
showInstructions: true,
skipApiSubmission: false,
useStrictMode: false,
extraPartnerParams: {
'custom_param_1': 'value1',
'custom_param_2': 'value2'
}
};
If you are authenticating an existing user you should use SmileIDSmartSelfieAuthenticationEnhancedView widget
<SmileIDSmartSelfieAuthenticationEnhancedView
style={styles.nativeView}
params={smartSelfieParams}
onResult={handleSuccessResult}
onError={handleError}
/>
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)
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
Allows for implementing retrieval of the Selfie & Liveness images without submitting a job. When set to true, a job submission will not be attempted, and only the images will be returned.
extraPartnerParams
Custom values specific to partners passed as an immutable map
colorScheme
See Theming
typography
See Theming
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)
Last updated
Was this helpful?