# Results

The Results module shows a screen summarizing the data captured during onboarding, including OCR fields, captured images, and identity scores. It returns an overall user score. The score includes ID validation, liveness, face recognition, and government validation, plus an overall value and status.

For an overview of this module and how it works, see [Show Results](https://developer.incode.com/docs/field-comparison).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it and let the back end drive the steps. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants. Adding Results while the SDK is in **Submit-Only Mode** has no effect; the step is silently skipped.

## Add Results

1. Add an [ID Capture](https://developer.incode.com/docs/module-id-scan) or [QR Scan](https://developer.incode.com/docs/module-qr-scan) module before Results. Results depends on the data those earlier steps produce.
2. Add a [Selfie](https://developer.incode.com/docs/module-selfie) module before Results. On iOS this is **required**. Flow configuration validation throws `ModuleConfigurationError.missingModule` if no Selfie module is present anywhere in the flow.
3. Add the module with `addUserScore()`:

   ```swift
   // Default fetch mode (Accurate)
   flowConfig.addUserScore()

   // Or choose how results are fetched
   flowConfig.addUserScore(userScoreFetchMode: .fast)
   ```

### Example

The example below adds ID Capture and Selfie before Results, then reads the overall score and status from `onUserScoreFetched(_:)` on the onboarding delegate.

```swift
flowConfig.addIdScan(scanStep: .both)
flowConfig.addSelfieScan()
flowConfig.addUserScore()

// IncdOnboardingDelegate
func onUserScoreFetched(_ result: UserScore) {
    let score = result.overall?.value   // for example, "80.5/100"
    let status = result.overall?.status
}
```

To fetch the score without presenting the results screen, use the headless API `IncdOnboardingManager.shared.getUserScore(userScoreFetchMode:interviewId:completion:)`, which returns the same `UserScore`.

## Configuration Options

Results has no builder. Its only option is the fetch mode passed to `addUserScore(userScoreFetchMode:)`.

| Option                        | Description                                                                             |
| ----------------------------- | --------------------------------------------------------------------------------------- |
| `UserScoreFetchMode.accurate` | Fetches the complete, precise score. This is the default (used when no mode is passed). |
| `UserScoreFetchMode.fast`     | Fetches results sooner, trading completeness for speed.                                 |

## Result

Results delivers a `UserScore` through the `onUserScoreFetched(_ result: UserScore)` callback on `IncdOnboardingDelegate`.

```swift
func onUserScoreFetched(_ result: UserScore)
```

`UserScore` fields:

- `overall: Result?`: The overall score and status; `nil` when unavailable.
- `idValidation: IDValidation?`: The ID verification checks.
- `liveness: Liveness?`: The liveness checks.
- `faceRecognition: FaceRecognition?`: The face recognition checks.
- `governmentValidation: GovernmentValidation?`: The government validation checks.
- `extendedUserScoreJsonData: Data?`: Additional score data as raw JSON.
- `error: IncdError?`: The error, if one occurred.

`Result` carries `value: String?` (for example, `"80.5/100"`) and `status: Status?`. `Status` is one of:

- `ok` (`"OK"`): Passed.
- `warning` (`"WARN"`): Passed with warnings.
- `fail` (`"FAIL"`): Failed.
- `unknown` (`"UNKNOWN"`): Status could not be determined.
- `manual` (`"MANUAL"`): Manual review needed.

The per-category structs expose their own `overall: Result?` plus category-specific detail:

- `IDValidation`: `overall`, `photoSecurityAndQuality: [IDCheck]?`, `idSpecific: [IDCheck]?`.
- `Liveness`: `overall`, `livenessScore: Result?`, `photoQuality: PhotoQuality?`.
- `FaceRecognition`: `overall`, `croppedFace: String?` (Base64-encoded), `croppedIDFace: String?` (Base64-encoded), `existingUser: Bool?`.
- `GovernmentValidation`: `overall`, `recognitionConfidence: Result?`, `validationStatus: IDCheck?`, `ocrValidation: [IDCheck]?`.

Each `IDCheck` carries `key: String?`, `value: String?`, and `status: Status?`.

Errors surface through `UserScore.error` as an `IncdError`; for the complete case list, see [Common Types](https://developer.incode.com/docs/ios-api-reference#common-types). This module does not deliver a module-specific error type.

<br />
