# QR Scan

The QR Scan module captures the QR code on the back of an ID, decodes its identity data, and sends it to the server. Your Incode Flow or Workflow configuration determines whether the module runs and what the decoded payload is used for. QR Scan requires camera access; the SDK requests the camera permission during the flow. See [Add Required Permissions](https://developer.incode.com/docs/setup-ios#add-required-permissions).

You add this module in code by adding it to your `IncdOnboardingFlowConfiguration` (`flowConfig`), as shown on this page. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration) for how to define and run the flow.

**Availability:** All variants.

## Add QR Scan

1. Add the module with `addQRScan()`.
   ```swift
   flowConfig.addQRScan(showTutorials: true)   // omit or pass nil to use the default
   ```
2. If your flow includes the Video Conference, User Consent, or Government Validation modules, add them after QR Scan. Adding any of those modules before QR Scan throws `ModuleConfigurationError.invalidOrder`.

## Configuration Options

Configure the module with `addQRScan()`.

| Option          | Type    | Notes                                                                                                                                                                      |
| --------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `showTutorials` | `Bool?` | Shows tutorial screens that explain the QR scan process before capture. `nil` uses the manager default (`IncdOnboardingManager.shared.showQRTutorials`, `true` by default) |

## Result

```swift
func onQRScanCompleted(_ result: QRScanResult)
```

`QRScanResult` fields:

- `success: Bool?`: Whether the scan succeeded.
- `error: IncdError?`: The error when the scan did not succeed; otherwise, `nil`.

<br />
