> For the complete documentation index, see [llms.txt](https://legacy-docs.usesmileid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://legacy-docs.usesmileid.com/integration-options/mobile/products/smartselfie-tm-enhanced.md).

# Enhanced SmartSelfie™ Enrollment And Authentication

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:

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.SmartSelfieEnrollmentEnhanced`

```kotlin
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`

```kotlin
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
        }
    }
}
```

```swift
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

```swift
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)")
    }
}
```

```dart
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

```dart
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
                }
            ),
        ),
    ),
);
```

```typescript
<SmileIDSmartSelfieEnrollmentEnhancedView
  userId="random-user-id/generated-user-id"
  allowAgentMode={false}
  forceAgentMode={false}
  style={{ width: '100%', height: '100%' }}
  onResult={(event) => {
    setResult(event.nativeEvent.result);
  }}
/>
```

If you are authenticating an existing user you should use SmileIDSmartSelfieAuthenticationEnhancedView widget

```typescript
<SmileIDSmartSelfieAuthenticationEnhancedView
  userId="random-user-id/generated-user-id"
  allowAgentMode={false}
  forceAgentMode={false}
  style={{ width: '100%', height: '100%' }}
  onResult={(event) => {
    setResult(event.nativeEvent.result);
  }}
/>
```

Before using the widgets, define a `SmartSelfieParams` object to configure the SmartSelfie™ flow:

```typescript
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

```typescript
 <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 [Customization](/integration-options/mobile/theming.md#theming)

**`typography`**

See [Customization](/integration-options/mobile/theming.md#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)`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://legacy-docs.usesmileid.com/integration-options/mobile/products/smartselfie-tm-enhanced.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
