# Antifraud

The Antifraud module compares the current session against prior sessions and known identities to detect signs of fraud. Its screen is designed to execute in the background; it only appears briefly while the check completes.

For an overview of this module and how it works, see [Antifraud Check](https://developer.incode.com/docs/antifraud-check).

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 by ID and let the back end drive the steps. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants.

## Add Antifraud

Add the module with `addAntifraud()`. Add Antifraud as the last module in your flow. The one exception is when you also use the Custom Watchlist module. In that case, call `addAntifraud()` first, then `addCustomWatchlist()`.

```swift
flowConfig.addAntifraud()
```

## Configuration Options

Antifraud has no configurable settings.

## Result

```swift
func onAntifraudCompleted(_ result: AntifraudResult)
```

`AntifraudResult` fields:

- `response: AntifraudResponse?`: The outcome of the antifraud check, including its result status and which check produced it; `nil` when no response was obtained. See `AntifraudResponse` below.
- `error: IncdError?`: The error that occurred while checking for fraud, if any; otherwise, `nil`.

`AntifraudResponse` fields:

- `result: AntifraudStatus`: The outcome of the antifraud check: `FAILED`, `PASSED`, `NOT_EXECUTED`, or `UNKNOWN`.

- `stepName: AntifraudStepName?`: The antifraud check that produced this result: `FuzzyFieldAntifraudExecutor`, `IdFaceAntifraudExecutor`, `SelfieFaceAntifraudExecutor`, or `UNKNOWN`.

## Headless

```swift
IncdOnboardingManager.shared.antifraudCheck { result in /* AntifraudResult? */ }
```

<br />
