SmartComply iOS SDK
The SmartComply iOS SDK is a native Swift library that delivers a fully self-contained identity verification flow for iOS apps. Drop in one SwiftUI view and the SDK handles session management, country and ID-type selection, document capture, identity verification, and liveness detection automatically.Features
- Drop-in SwiftUI view —
SmartComplyFlowViewmanages the entire verification flow with no UI code required - Two verification modes — document photo capture or ID number data entry, configured from your Dashboard
- Guide-box document capture — crops exactly what falls inside the ID card frame so the image sent to the backend is always clean
- ID photo checked on the phone: for passports and the older Kenyan national ID, with every other document checked by the backend as before, the code at the bottom of the document is read on the device before upload, so a cut-off or blurred photo is retaken before it costs a check. See Checking the photo on the phone
- Upload a photo or a PDF: the user can pick a photo from the library, or a photo or one-page PDF from Files. See Uploading a PDF
- ID checked before the selfie: the backend reads the ID and checks it against the government registry first, so a cropped or misread ID is retaken on the spot. See Document check
- Liveness detection — a passive face scan (blink plus natural head movement) runs automatically after identity verification, with no step-by-step prompts
- Dynamic ID types — channels and fields are fetched live from your Dashboard configuration
- Choose your document: the user picks the issuing country from an A to Z list, searchable from 7 countries, then the document. Countries and documents come from your Dashboard. See Choose your document
- Dark and light mode — theme adapts to the system colour scheme; override with
preferredColorScheme - Automatic upload retry — transient upload failures are retried internally
- Your brand, not ours: name, description, colour and logo come from the Dashboard, and the font is passed by your app. See Branding
- Any backend host: production, staging, or your own, without a rebuild
- Resubmit: a failed verification can be reopened from the Dashboard, and the customer redoes only the step that failed. See Resuming a failed verification
Requirements
- iOS 16.0 or later
- Xcode 16 or later. The shipped XCFramework’s module interface names
SwiftUICorein public signatures, a module that first ships in the iOS 18 SDK, so Xcode 15 cannot compile it - A physical device that supports ARKit face tracking. Liveness gates on
ARFaceTrackingConfiguration.isSupported, which covers iPhone X and later as well as A12 and later devices without a TrueDepth camera. Liveness cannot run in the Simulator
Installation
The SDK is distributed via Swift Package Manager as a precompiled XCFramework. The package you add contains the Swift Package manifest; Xcode downloads the binary automatically and embeds it in your app.Xcode (recommended)
- Open your project in Xcode
- Go to File → Add Package Dependencies
- Enter the repository URL:
https://github.com/386konsult/smartcomply-ios-sdk - Select Up to Next Major Version and enter
1.7.1 - Click Add Package and select the SmartComplySDK library
Package.swift
1.7.1 reports its own version. 1.7.0 identified itself to the backend as 1.6.1.
Nothing else changed, so no code changes are needed.
1.7.0 returns a session reference.
createSession() now returns reference
alongside token and expiresAt: the backend’s ID for the session, or nil when the
backend does not return one. Only an integration that drives the modules itself gets
it. SmartComplyFlowView creates its own session and does not pass the reference to
your app. No code changes are needed, the SDK still has no third-party dependencies
and no new Info.plist key is needed.1.6.1 adds a Choose your document step. iOS 1.6.0 was published without these changes
and is the same as 1.5.0, so use 1.6.1. After Welcome the user picks the issuing
country, then the document, from the countries and documents on your SDK Config.
Documents go up as given, up to 10 MB, with location and other personal metadata
removed. An expired document now reaches liveness with a warning and ends
"failed".
FlowResult gains documentCountry and passportCheckProblems. No code changes are
needed, the SDK still has no third-party dependencies and no new Info.plist key is
needed. See Choose your document,
Document images and FlowResult.1.5.0 accepts a PDF of the ID. Upload from library now opens a sheet with two
choices: Photo library, the photo picker as before, and Files, which takes a
JPG, PNG or one-page PDF up to 5 MB. A PDF is checked on a Check your file screen
and uploaded unchanged. No code changes are needed, no public API changed and the SDK
still has no third-party dependencies. See Uploading a PDF.
1.4.0 checks the ID photo on the phone. For a Kenyan national ID (back) and a
passport, the review screen reads the code at the bottom of the document with Apple’s
Vision framework before upload and asks for a retake if it is cut off or unclear. The
SDK still has no third-party dependencies. See
Checking the photo on the phone.
1.3.0 adds Resubmit. Pass the resume token from a Dashboard Resubmit to
SmartComplyFlowView and the customer redoes only the step that failed. It changes
nothing for a flow presented without one. A dead token ends in onDismiss with
errorCode "RESUME_LINK_INVALID". See
Resuming a failed verification.1.2.0 checks the ID before the selfie, and holds the selfie until the whole face
is in the circle. The ID now goes up on its own and the backend reads it and
checks it against the government registry before the liveness camera opens, so a
cropped or misread ID is turned back with a retake screen instead of failing after
the whole flow. The selfie and the scan then wait until the user’s whole face is
inside the circle, with no timeout.
onDismiss has two new causes. Read
Document check and Liveness before you upgrade.1.1.0 reworks the liveness screen and changes when the selfie is taken.
Verification now happens in place, on a frozen blurred preview, instead of
cutting to a separate progress screen. The guide is a circle rather than an
oval. And the autoshot waits for a properly framed face rather than firing on a
timer, which adds up to 2.5 seconds for a user slow to get into frame and
nothing for one already there. 1.2.0 removes that 2.5 second limit; see
Liveness.
Take 1.0.4, not 1.0.3. Up to 1.0.3 the front check required a face, and
rejected genuine IDs whose portrait is engraved rather than printed, Kenya’s
Maisha Namba card among them, with “No face detected”. 1.0.4 judges the front
on text instead. See Document images.
1.0.3 changes two behaviours.
FlowResult.status now holds the real verdict, and the success
screen no longer means a pass. Read FlowResult before upgrading from 1.0.2 or
below. It also adds Branding and a custom backend host.iOS and Android are versioned separately. Up to 1.1.x the numbers never lined up; 1.2.0,
1.3.0, 1.4.0, 1.5.0 and 1.7.0 ship the same changes on both under the same number. Android 1.6.0 matches iOS 1.6.1.
Android 1.2.1 is an Android-only fix with no iOS counterpart, and iOS 1.7.1 is an iOS-only fix
with no Android counterpart.The package URL is
smartcomply-ios-sdk, which is not the same as the SDK’s source repository.
It ships both device and simulator slices, so the same dependency builds for a physical device
and the Simulator without extra configuration.Platform Setup
Add the following key to your app’sInfo.plist:
PHPickerViewController, which runs out of process and requires no photo-library key. From 1.5.0 the Files choice uses the system document picker, which needs no key either.
Credentials
Both values come from your Adhere Dashboard and both are permanent. Reuse the same pair for every verification.Quick Start
1. Create the SDK instance
Create aSmartComply instance once, for example in your view model or app entry point.
2. Present the flow view
EmbedSmartComplyFlowView anywhere in your SwiftUI hierarchy. The SDK loads automatically when the view appears.
- Creates a secure session
- Displays a welcome screen with your logo. Up to 1.5.0 it also held the ID type cards
- From 1.6.1, Choose your document: the issuing country, then the document. See Choose your document. Up to 1.5.0 a country picker on the welcome screen, shown when multiple countries are configured
- User photographs the front of their ID inside the guide box. From 1.5.0, Upload from library offers a photo from the library or a JPG, PNG or one-page PDF from Files. See Uploading a PDF
- Photographs the back, when the Dashboard’s
requires_back_sidefor that ID type isrequiredoroptional. Onoptionalthe capture screen also shows a This ID has no back side control; tapping it goes straight to the document check with no back image. When the backend sends no value at all, the SDK falls back to matching the ID type’s name against national, driver, resident and voter - From 1.2.0, uploads the ID on its own and waits for the backend to read it and check it against the registry. A rejected ID gets a retake screen; an accepted one shows Are these your details? See Document check
- Runs the passive liveness scan on the same entry
- Returns a
FlowResultto your completion handler
- Creates a secure session
- Displays a welcome screen with ID type selection
- Shows a country picker if multiple countries are configured. From 1.2.0 Continue stays disabled until a country is picked. From 1.6.1 it is an Issuing country row that opens the same list as Choose your document
- User enters their ID number and any required fields
- Identity is verified against the national database
- Runs the passive liveness scan
- Returns a
FlowResultto your completion handler
Choose your document
From 1.6.1, in document mode, Continue on the welcome screen opens Choose your document: the Issuing country row, then the documents offered for that country, each with “Photo page” or “Front and back” under its name. Tapping a document opens the camera.
Search ignores case and accents, so “cote” finds Côte d’Ivoire. When nothing matches, the
user is told to check the spelling or try the English name, and that only the countries
this service accepts are listed.
The countries and documents come from your SDK Config on the Dashboard, so they change
without an app release. The verification is created with the country’s ISO code as the
Dashboard sends it, so a newly enabled country works without an SDK update. A tenant with
no countries configured goes from the welcome screen straight to the camera, as before.
Choose a different ID on a rejected document and back from the camera return to this
screen. Data mode has no document step: when more than one country is configured, it shows
the same country row and list on the welcome screen.
Document check
From 1.2.0 the ID is checked before the liveness camera opens. Up to 1.1.0 it went up with the selfie once the scan had started, so a cropped or misread ID was only rejected after the whole flow, and Try Again threw away both photos. After the last photo the SDK uploads the ID on its own, polls for the result for up to 90 seconds, and shows the user one of these:
The message on the rejection screens is the backend’s own. A retake reuses the same entry,
and liveness then submits to that entry rather than creating a new one. A rejected ID is
not billed. End session and Close call
onDismiss with errorCode
"DOCUMENT_REJECTED" or "MANUAL_REVIEW_REQUIRED"; without an onDismiss, End session
returns the user to choosing a document.
From 1.6.1 an expired document is not stopped here. When the backend reads it and lets
it through, Are these your details? shows the expiry date marked “Expired” and this
warning, which VoiceOver announces: “This document has expired. You can continue, but a
check with an expired document won’t be approved. Use a valid document if you have one.”
The user can continue to liveness or retake with another document. A verification that goes
on with an expired document ends with status "failed".
Data mode is unchanged: it has no document to check.
Checking the photo on the phone
From 1.4.0, before a photo is uploaded, the SDK reads the machine readable zone (the two or three lines of letters, numbers and< at the bottom of the document) on the
phone with Vision and checks every line is there and every check digit adds up. A
cut-off, blurred or covered photo is caught in under a second, instead of after the
backend has read it.
This is an extra check in front of the backend, not a limit on which documents are
supported. Every document type your Dashboard offers still works on both SDKs. More
documents will get the check on the phone as their code formats are confirmed.
What the user sees on the review screen:
The message says the document is cut off or unclear, or, when no code is found at all,
that the user may have photographed the wrong side. VoiceOver announces it.
The check never blocks a photo it cannot judge. If Vision cannot run, the check takes
longer than 5 seconds, or the card is a different Kenyan ID (the Maisha Namba), the photo
goes through exactly as in 1.3.0 and the backend checks it. A photo picked from the
library is checked too, including one taken sideways. Nothing read from the code is sent
anywhere or logged.
From 1.5.0 the code is read more reliably, on photos and PDFs alike:
- A rotated page, such as a scan saved sideways, is read correctly.
- A letter cut off at the edge of the passport number is repaired, but only when every check digit agrees with the repair.
- Stray marks at either end of a code line are ignored.
< fillers, joins the two
lines into one, or misses a line with a full personal number. Every repair must still pass
the check digits, so a passport that really is cut off still fails.
Uploading a PDF
From 1.5.0, Upload from library opens a sheet titled Upload your ID with two choices:
A photo picked from Files goes through exactly the same review and checks as a photo from
the library. A PDF gets its own screen, Check your file, which shows page 1, the file
name, its size and its page count, with Use this file and Retake or choose another.
The PDF is uploaded unchanged, as
application/pdf, named document.pdf for the front and
document_back.pdf for the back. It is not converted to an image or re-encoded. You do not
need to change any code, and no public API changed.
A file the SDK cannot use is refused on the phone before anything is uploaded. The user
sees the message and Retake or choose another, and VoiceOver announces it:
On a passport photo page and the back of the older Kenyan ID, page 1 of the PDF gets the
same check on the phone as a photo, worded for a file. See
Checking the photo on the phone. While it runs the
screen says “Checking your file” and Use this file waits. The first and second
failures offer Retake or choose another only. From the third failure on the same side,
Use this file anyway appears, and the backend checks the file as before. Photos and
PDFs count together towards those three failures. Every other document skips the check,
exactly as a photo does.
The SDK still has no third-party dependencies. The PDF is opened with PDFKit and its code
is read with Vision, both part of iOS.
Document images
From 1.6.1 documents go up as given. The limit is 10 MB for the front and the back alike, and a file over it is refused on the phone with its size. See Uploading a PDF.
Photo library and Files are handled the same way. The photo library hands the SDK the
original file rather than a copy the system has converted.
Up to 1.5.0 document photos were capped at 5 MB server-side. Both routes, the in-SDK
camera and Upload from library, were downscaled to 1280px on the long edge and
re-encoded as JPEG at quality 0.72, and in 1.5.0 a photo picked from Files was downscaled
the same way. A PDF went up as picked and was refused on the phone over 5 MB.
Before the review screen the SDK checks the front photo looks like a document: from 1.0.4
that means at least three regions of text. A failure is a warning, not a block. The user can
still confirm, because a false negative would otherwise trap someone holding a genuine but unusual
ID. The backend is the check that actually rejects, and from 1.2.0 it does so before the selfie:
see Document check. From 1.4.0 the back of a Kenyan ID and a passport photo
page are also checked on the device: see Checking the photo on the phone.
Resuming a failed verification
From 1.3.0. When a verification fails, your team can click Resubmit on it in the Adhere Dashboard. That issues a single-use resume token, valid for 24 hours. Present the flow with it and the customer redoes only the step that failed, on the same verification, instead of starting again.1
Receive the token on your backend
It arrives in the
liveness.resubmit_requested webhook.
Without a webhook URL on your SDK Config, it is shown in the Resubmit dialog for your
team to copy.2
Get it to the customer's app
Getting it onto the phone is up to you; see the warning below.
3
Present the flow with it
The result comes back exactly as for any other run:
onComplete with result.status, and a
liveness.completed webhook with the same verification_id as the original.
A token that is expired, already used, or replaced by a newer Resubmit shows a “Link No
Longer Valid” screen. Its Close calls onDismiss with errorCode "RESUME_LINK_INVALID";
without an onDismiss the screen has no Close button. Issue a new token rather than presenting
the flow without one, which would start an unrelated verification.
The attempt limit carries over. Three failed attempts per verification, counted across the
original session and the resume. A verification that has used them cannot be resubmitted; it
goes to manual review instead. A customer who reaches the limit during the resume sees the same
We couldn’t finish your verification screen as in Document check.
Driving the modules yourself, call try sdk.resumeSession(token) in place of
createSession(), then try await sdk.resumeInfo() to learn which step to open. Do not call
createSession() after it: a new session replaces the token and the resume is silently lost.
Environments
.sandbox targets a server running on the device itself, for local backend development. It is not a hosted test environment. Use .production for all integration work.
A different host
SDKEnvironment covers the two hosts you ship against, and one of them is
loopback on the handset. For anything else, a staging deployment or a QA build
that has to reach more than one backend without being rebuilt, override it. Added
in 1.0.3.
environment rather
than being treated as a host, so a build reading this off an empty field does not
post verifications to a relative URL.
Branding
The flow carries your brand, not Adhere’s. Colour and logo come from the SDK Config on the dashboard, so they change without an app release, and your name is shown while the session is being set up. The font is the one exception and is passed by the host.
The welcome heading and subheading are fixed SDK copy: “Verify Your Identity”, then one of two
lines keyed off the verification mode.
Logo
Upload it under Settings → Integrations → SDK → Brand Details. PNG, JPEG or WebP, up to 512 KB and 1024x1024 pixels. Requires 1.0.3. It is drawn on its own, with no box or border behind it, and bounded by height rather than fitted into a square so a wordmark stays legible. Only the SDK’s fallback shield sits in a tinted frame. The logo belongs to the SDK Config, not the company. A branch running several configs for different products gives each its own mark, and a config with no logo shows the SDK’s own shield rather than falling back to the company logo on your profile page. If you want the same mark everywhere, upload it to each config.A logo never delays or blocks a verification. The SDK fetches it after the
welcome screen is already on screen, on a three second budget, and keeps its own
shield if the fetch fails. It is also decoded through a pixel cap, so an
oversized image cannot exhaust memory on the handset.
Font
Passed by your app, because the SDK neither ships nor downloads font files: your loading, caching and licensing stay yours. Requires 1.0.3. A face listed underUIAppFonts, or registered at runtime, is available
process-wide, so the SDK needs only its PostScript name.
Font.custom(_:size:) selects a face by name and
takes no weight argument, so a single name would render every screen at one
weight. Only regular is required; anything omitted falls back to the nearest
name you did supply.
A name that is not registered logs a warning under the
com.smartcomply.sdk
subsystem and falls back to the system font rather than rendering nothing.
Dynamic Type still applies either way.Liveness
Two actions are drawn from.blink and .turnHead in random order and detected passively. Both are watched on every frame, neither is named to the user, and the HUD only reports how many are done: there is no prompted sequence.
Head yaw is measured against the phone, not against the world, and frames during which the device itself is rotating are not credited: turning the handset does not satisfy the challenge.
The scan has a 20 second cap.
The screen, from 1.1.0
The guide is a circle rather than an oval, and verification happens in place. Earlier versions cut to a separate progress screen the moment the capture was submitted, so the result poll began by throwing away the thing the user was looking at. The preview now freezes on its last frame, blurs, and the guide is replaced by a dotted ring while the poll runs underneath; the checkmark lands in the same circle. ARKit is paused as soon as the preview freezes. Nothing past.uploading reads
another frame, so the camera indicator no longer stays lit for the whole poll.
LivenessOrchestrator.stopCamera() is public if you drive the orchestrator
yourself.
When the autoshot is taken
Two stills leave the device. The autoshot is taken before the scan and the snapshot once both actions are done. From 1.2.0, in document mode the autoshot goes up with the video, because the entry already exists from the document check; in data mode it goes up with the entry as before. From 1.2.0 nothing starts until the whole face is inside the circle. After a 300ms settle the SDK holds the autoshot until three consecutive frames put the face inside the circle the user is looking at, and there is no timeout. Recording and the 20 second cap start only then. Up to 1.1.0 the check looked at the centre of the face alone, so a face with its chin well below the circle passed, and after 2.5 seconds it took whatever ARKit saw.- “Whole face” is ARKit’s face mesh. The ellipse around the mesh, forehead to chin and
cheek to cheek, is projected into the preview with
ARFrame.camera.projectPointand must sit entirely inside the circle. On an iPhone 13 Pro the projected outline traced the face. - The prompt says what is wrong. “Position your face in the frame” when there is no face, “Move back a little” when the face is centred but too big to fit, and “Fit your whole face inside the circle” when it is off to one side or too low. It stays up until the face is in.
- During the scan an action only counts while the face is in the circle. If the face is out for more than half a second the prompt comes back and nothing is credited until it returns. The grace keeps a head turn, which swings the face across the edge, from flashing the prompt.
- Framing is not cosmetic. Measured on device, a selfie with the face in the corner of the frame scored 25.6% against the ID photo and was reported as a mismatch; the same person framed in the guide scored 67%.
Accessibility
From 1.0.3 the flow honours the user’s text size setting (Settings → Accessibility → Display & Text Size → Larger Text). Earlier versions used fixed point sizes throughout, so the setting had no effect on any screen. Scaling is capped at.accessibility1. The liveness guide, the document frame and the buttons are sized to fit their content, and the accessibility sizes above that cap overflow them: the bound keeps everything below it usable rather than shipping layouts that break at the top of the range.
What “Verification Complete” means
Nothing about the verdict. Every submitted entry reaches that screen, whether the backend passed or failed the check. The submit call returnsprocessing, because the backend resolves face matching on a worker moments later. The SDK polls for up to about 15 seconds and puts whatever it learns in FlowResult.status, then shows the success screen either way. A user who failed is not told so and is not offered a retry.
This is a product decision, not an oversight: tenants asked for the end user to see a submitted verification as accepted, and to act on the real verdict themselves from the dashboard and the webhook. It means you have to close the loop with a user who failed.
Pre-submission failures are unaffected and still show their own screens: a denied camera, a configuration or network error, reaching the 20 second liveness cap, and from 1.2.0 a rejected ID. Nothing has been billed at that point and the user can recover on the spot.
Knowing the user gave up
onComplete only fires on a verification. Pass the optional onDismiss to learn that the flow ended without one: the user closed the failure screen, an error left nothing to retry, or from 1.2.0 the user ended the session on a rejected ID. Passing it also adds a Close control to the failure screen, which otherwise offers only Try Again.
SDK Configuration
FlowResult
Delivered to youronComplete closure when the user completes the flow in-app.
The 1.6.1 fields are empty for now.
documentCountry is the document’s issuing
country and passportCheckProblems lists the passport fields whose check digit doesn’t
add up; see Passport check problems
for each value. Both are read from the result poll, which does not send them to the
mobile SDKs yet. Until it does, documentCountry is nil and passportCheckProblems is
[], and they stay that way on a "processing" result. Read both from the
webhook in the meantime. A passport check problem is a
warning, not a verdict: branch on status.verifiedName and idNumber are populated from the poll as well as from submit, from 1.0.3.
In document mode they previously appeared only when OCR happened to finish before the user
completed liveness, so whether a user saw their own name came down to timing.From 1.0.2 both are populated. In document verification they come from the OCR of the captured
document; in data verification they come from the identity provider’s response.
verifiedName is
the full name where the provider sends one, otherwise it is composed from the first, middle and
last name fields.They are still only as good as the submission that produced them, so treat them as a receipt of
what was read, not as a verdict. The webhook remains the source of truth for the final outcome.The webhook is still the system of record. An entry’s status moves through
pending,
processing, and then passed, failed or expired, and the final status, the extracted fields
and any failure reason are delivered to the webhook URL configured on your SDK Config. See
Webhooks for the full payload.What changed in 1.0.3 is that onComplete no longer fires ahead of that verdict. It waits for
the backend to reach a terminal status, so status agrees with what the webhook will say. Reconcile
from the webhook for anything you persist: a run that has not resolved in about 15 seconds still
returns "processing".Error Handling
SmartComplyFlowView handles and displays error states automatically. For the headless API, all SDK methods throw on failure:
SDKError exposes message: String, statusCode: Int and errorCode: String?. AuthError, NetworkError and AlreadySubmittedError all subclass it, so a single catch let error as SDKError covers every case.
From 1.0.3 the error carries the backend’s own code.
errorCode was previously hardcoded to
AUTH_ERROR for every 401 and 403, so SDK_CONFIG_NOT_FOUND, an expired session and an invalid
key were indistinguishable and host logic keyed on the code could not work. Validation failures
likewise reported only the generic "One or more fields failed validation."; the per-field reason
is now surfaced.AlreadySubmittedError is raised when an upload retry is rejected as a duplicate, which means the
original attempt reached the server and the entry exists and was billed: the response was simply
lost coming back. The bundled flow treats it as such and reads the outcome rather than reporting a
failure. Handle it the same way if you drive the modules yourself.
