ScreenlyyIDDocs
Docs › Recipes

iOS (Swift)

View as Markdown

The ScreenlyyID iOS 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 or 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 page. The example's README explains how to run both parts on a real device (the simulator has no camera).

The pieces to copy:

WhatFile in the example
Ask the back end for a session and for the resultDemoCamera/LaunchViewController.swift (Backend)
Ask for camera permission before loading the page, send the user to Settings if deniedDemoCamera/HomeViewController.swift
WKWebView with the event listener (a WKUserScript forwards message events)DemoCamera/ViewController.swift
One request for the result after IDV_SESSION_COMPLETEDemoCamera/SuccessViewController.swift
The server routesbackend/server.mjs