# iOS (Swift)

> Add ScreenlyyID identity verification to an iOS app: a back end that calls the API, and an app that opens the hosted page in a WebView.

Canonical URL: https://www.screenlyyid.com/docs/recipes/ios/

The [ScreenlyyID iOS example](https://github.com/ScreenlyyID/ios-sdk-example) is the reference for a native iOS app. It has two parts, and the split matters:

- **`backend/`**: a small Node server that holds the API key and the `CorrelationId` and makes every ScreenlyyID call. You can swap it for your own server, for instance the [Express](https://www.screenlyyid.com/docs/recipes/express/) or [FastAPI](https://www.screenlyyid.com/docs/recipes/fastapi/) recipes, which have the same two routes.
- **`DemoCamera/`**: the app. It contains no API key. It asks the back end to create a verification, asks for camera permission, opens the `webEnrolmentUrl` in a `WKWebView`, listens for `IDV_SESSION_COMPLETE` and `ERROR`, then asks the back end for the result.

Follow the steps and the camera-permission notes on the [Mobile app](https://www.screenlyyid.com/docs/integrations/mobile-app/) page. The example's README explains how to run both parts on a real device (the simulator has no camera).

The pieces to copy:

| What | File in the example |
|---|---|
| Ask the back end for a session and for the result | `DemoCamera/LaunchViewController.swift` (`Backend`) |
| Ask for camera permission before loading the page, send the user to Settings if denied | `DemoCamera/HomeViewController.swift` |
| `WKWebView` with the event listener (a `WKUserScript` forwards `message` events) | `DemoCamera/ViewController.swift` |
| One request for the result after `IDV_SESSION_COMPLETE` | `DemoCamera/SuccessViewController.swift` |
| The server routes | `backend/server.mjs` |
