Devices and offline sync
Run face check-in on your own devices: offline, 1:1 against the scanned ID, with liveness checks.
Check-in devices (phones, tablets or kiosks at the entrance) run the FacePing SDK. Each device holds an encrypted copy of one check-in list's face templates and checks people on the device itself: no network needed at the point of check-in, and no face data leaves the device.
1. Add each device to the list#
Never put an API key on a check-in device. Add the device to a list instead: you get a device token (token, starting fpd_) that is read-only, for that one list. For a list with an end date it expires with the list's retention; for an ongoing list, or any practice list in the sandbox, it lasts until you revoke it or delete the list (expiresAt is null). The token is shown only once. Add a device in Dashboard → Check-in lists → your list → Devices, or:
POST /v1/lists/{listId}/devices →
Check a device token#
Check a token works before it goes into an app: send it in the X-Device-Token header (not X-Api-Key) to GET /v1/device. You get the list it's for, how many people a device would download and when it expires. It downloads no faces and doesn't count as a sync. A mistyped or revoked token, or one whose list has been deleted, gets 401. The message says if a token was revoked; a deleted list's tokens are deleted with it, so the API can't tell one from a mistyped token and says it may be either. A sandbox key or API key sent in X-Device-Token gets a 401 that names it: keys go in X-Api-Key.
See and revoke devices#
See a list's devices and when each last synced (lastSyncAt):
GET /v1/lists/{listId}/devices →
Lost a device? Revoke it (with the id from adding or listing it): it wipes its copy at its next sync. Revoking a device that's already revoked also returns 204, so it's safe to retry. (Deleting a list is different: the list is gone, so a second delete gets 404.)
DELETE /v1/lists/{listId}/devices/{deviceId} →
From your server:
# Add a device: keep the token (fpd_…), it's shown once
curl -X POST $FACEPING/v1/lists/$LIST_ID/devices \
-H "X-Api-Key: $FACEPING_API_KEY" -H "Content-Type: application/json" \
-d '{"label": "North entrance, lane 2"}'
# See the list's devices and when each last synced (lastSyncAt)
curl $FACEPING/v1/lists/$LIST_ID/devices -H "X-Api-Key: $FACEPING_API_KEY"
# Check a device token (in its own header, not X-Api-Key)
curl $FACEPING/v1/device -H "X-Device-Token: $DEVICE_TOKEN"
# Revoke one (its id from the two calls above)
curl -X DELETE $FACEPING/v1/lists/$LIST_ID/devices/$DEVICE_ID -H "X-Api-Key: $FACEPING_API_KEY"
Try it on your practice list#
Everything on this page works in the sandbox. Add a device to your practice list with your sandbox key (FACEPING_API_KEY=fp_test_…) or on the list's Devices tab in the sandbox dashboard, check it with GET /v1/device, then put the device token in your app instead of the sandbox key. Enrol people on the server (the SDK's enrol isn't available on a device), and verify them by personId. The device syncs the practice list like a live one, and its lease is cut short so a face never stays on the device past its 24 hours. Each Get started guide ends with the steps for its platform: .NET MAUI, Avalonia, Android, iOS, Flutter, React Native and Capacitor.
2. Put the device token in your app#
The SDKs run on Android 7.0+ and iOS 15.1+: .NET MAUI, Avalonia, Android (Kotlin), iOS (Swift), Flutter, React Native and Capacitor. One exception: a Capacitor app added with Swift Package Manager needs iOS 16+ (iOS 15.1+ with CocoaPods). A check-in device sets FacePing up with its device token instead of a sandbox key. The region defaults to the EU, where every account is today.
// MauiProgram.cs
builder.UseFacePing(o => o.DeviceToken = "fpd_…"); // this device's token// FaceCheck.Android/Application.cs and FaceCheck.iOS/AppDelegate.cs
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) =>
base.CustomizeAppBuilder(builder).UseFacePing(o => o.DeviceToken = "fpd_…");// Application.onCreate
FacePing.init(this, deviceToken = "fpd_…")// App.init
try FacePing.configure(deviceToken: "fpd_…")// main(), before runApp
await FacePing.init(deviceToken: 'fpd_…');// once, at start-up
await FacePing.init({ deviceToken: 'fpd_…' });// once, at start-up
await FacePing.init({ deviceToken: 'fpd_…' });That's fine for trying a device out. Don't build a token into an app you publish: pair each device instead.
Pair each device#
Build one app for every device and give each device its own token when it's set up: a pairing screen where staff paste the token (or scan it from a QR code you make of it), or your MDM pushing it to the device. The app keeps the token in the device's secure storage and hands it to FacePing on every launch. A mistyped or revoked token fails at once, so the pairing screen can say so: on a new device the first sync throws a setup error, and on a device that was paired before it comes back as revoked (and the device keeps nothing). With no connection the device still starts, and the people from its last sync keep working until the lease runs out.
// MauiProgram.cs: no key or token here
builder.UseFacePing();
// MainPage.xaml.cs: on launch, pair with the saved token, or show the pairing screen
protected override async void OnAppearing()
{
base.OnAppearing();
var token = await SecureStorage.GetAsync("faceping-device-token");
if (token == null)
{
await Navigation.PushModalAsync(new PairPage(faceping)); // comes back here once paired
return;
}
try
{
await faceping.PairAsync(token); // syncs; offline is fine
}
catch (FacePingSetupException ex) // revoked, or its list deleted
{
SecureStorage.Remove("faceping-device-token");
Status.Text = ex.Message;
}
}
// PairPage.cs: shown until this device has a token
public class PairPage : ContentPage
{
public PairPage(IFacePing faceping)
{
var token = new Entry { Placeholder = "fpd_…" };
var status = new Label();
var pair = new Button { Text = "Pair this device" };
pair.Clicked += async (_, _) =>
{
try
{
await faceping.PairAsync(token.Text ?? "");
await SecureStorage.SetAsync("faceping-device-token", token.Text!.Trim());
await Navigation.PopModalAsync();
}
catch (FacePingSetupException ex) { status.Text = ex.Message; } // not a device token, or revoked
};
Content = new VerticalStackLayout { Padding = 24, Spacing = 12, Children = { token, pair, status } };
}
}// Application.cs and AppDelegate.cs: .UseFacePing() with no key or token
// MainView.axaml.cs. TokenStore is your secure storage (the Keychain on iOS, a Keystore-encrypted file on Android);
// PairPanel holds a TextBox (TokenBox) and a button that calls OnPair.
protected override async void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
if (TokenStore.Load() is { } token) await Pair(token);
else PairPanel.IsVisible = true;
}
async void OnPair(object? sender, RoutedEventArgs e) => await Pair(TokenBox.Text ?? "");
async Task Pair(string token)
{
try
{
await IFacePing.Current.PairAsync(token); // syncs; offline is fine
TokenStore.Save(token.Trim());
PairPanel.IsVisible = false;
}
catch (FacePingSetupException ex) // not a device token, or revoked
{
TokenStore.Clear();
Status.Text = ex.Message;
PairPanel.IsVisible = true;
}
}// On launch with the saved token, or from the pairing screen (in a coroutine).
// TokenStore is your secure storage, for example a file encrypted with an Android Keystore key.
// Returns null when paired, or the message to show.
suspend fun pair(context: Context, token: String): String? = try {
val faceping = FacePing.init(context, deviceToken = token.trim())
if (faceping.sync().status == SyncStatus.REVOKED) throw FacePingSetupException(REFUSED)
TokenStore.save(context, token.trim())
null
} catch (e: FacePingSetupException) { // a mistyped or revoked token
runCatching { FacePing.current.close() } // so the next token can start again
TokenStore.clear(context)
e.message
}
const val REFUSED = "That device token isn't valid or has been revoked."// On launch with the token saved in the Keychain, or from the pairing screen.
// Keychain stands for your Keychain wrapper.
func pair(_ token: String) async {
do {
let faceping = try FacePing.configure(deviceToken: token.trimmingCharacters(in: .whitespacesAndNewlines))
let sync = try await faceping.sync() // a mistyped or revoked token throws FacePingError.setup on a new device
guard sync.status != .revoked else { // and comes back revoked on a device that was paired before
FacePing.shared?.close()
Keychain.delete("faceping-device-token")
status = "That device token isn't valid or has been revoked."
return
}
try Keychain.save("faceping-device-token", faceping.options.deviceToken ?? token)
status = "\(sync.enrolled) people synced (\(sync.status))"
} catch {
FacePing.shared?.close() // so the next token can start again
Keychain.delete("faceping-device-token")
status = error.localizedDescription
}
}// With the flutter_secure_storage package. On launch: final saved = await storage.read(key: tokenKey);
// null shows the pairing screen. Returns null when paired, or the message to show.
const storage = FlutterSecureStorage();
const tokenKey = 'faceping-device-token';
Future<String?> pair(String token) async {
try {
final faceping = await FacePing.init(deviceToken: token.trim());
if ((await faceping.sync()).status == SyncStatus.revoked) {
return await _refused(refused);
}
await storage.write(key: tokenKey, value: token.trim());
return null;
} on FacePingSetupException catch (e) {
return await _refused(e.message); // a mistyped or revoked token on a new device
}
}
const refused = "That device token isn't valid or has been revoked.";
Future<String> _refused(String message) async {
await FacePing.currentOrNull?.close(); // so the next token can start again
await storage.delete(key: tokenKey);
return message;
}// With expo-secure-store. On launch: const saved = await SecureStore.getItemAsync(TOKEN_KEY);
// null shows the pairing screen. Returns null when paired, or the message to show.
import * as SecureStore from 'expo-secure-store';
const TOKEN_KEY = 'faceping-device-token';
export async function pair(token: string): Promise<string | null> {
let message: string;
try {
await FacePing.init({ deviceToken: token.trim() });
// A mistyped or revoked token throws on a new device, and comes back revoked on one that was paired before.
if ((await FacePing.sync()).status !== 'revoked') {
await SecureStore.setItemAsync(TOKEN_KEY, token.trim());
return null;
}
message = "That device token isn't valid or has been revoked.";
} catch (e) {
message = isFacePingError(e) ? e.message : String(e);
}
await FacePing.close(); // so the next token can start again
await SecureStore.deleteItemAsync(TOKEN_KEY);
return message;
}// tokenStore stands for your secure storage plugin. On launch: const saved = await tokenStore.get();
// null shows the pairing screen. Returns null when paired, or the message to show.
export async function pair(token: string): Promise<string | null> {
let message: string;
try {
await FacePing.init({ deviceToken: token.trim() });
// A mistyped or revoked token throws on a new device, and comes back revoked on one that was paired before.
if ((await FacePing.sync()).status !== 'revoked') {
await tokenStore.set(token.trim());
return null;
}
message = "That device token isn't valid or has been revoked.";
} catch (e) {
message = e instanceof Error ? e.message : String(e);
}
await FacePing.close(); // so the next token can start again
await tokenStore.remove();
return message;
}When you revoke a device, it wipes its faces at its next sync and the sync status is revoked: clear the saved token then, so the device shows the pairing screen again.
Move a device to another list, or retire it#
To move a device to another list (tonight's event after last night's, say), add it to the new list and pair it with that list's token: save the new token and start FacePing with it, exactly as above. At the device's first successful sync with the new token, FacePing wipes the old list's faces, then the new list's people arrive. Two lists' faces are never on a device together. Until that sync (with no connection, say) the device keeps the list it had.
To retire a device, or hand it back, unpair it: that deletes every face on it and forgets its list, so it can be paired with any token later. Clear the saved token too.
await faceping.UnpairAsync();
SecureStorage.Remove("faceping-device-token");await IFacePing.Current.UnpairAsync();
TokenStore.Clear();FacePing.current.unpair()
FacePing.current.close()
TokenStore.clear(context)try await FacePing.shared?.unpair()
FacePing.shared?.close()
Keychain.delete("faceping-device-token")await FacePing.current.unpair();
await FacePing.current.close();
await storage.delete(key: tokenKey);await FacePing.unpair();
await FacePing.close();
await SecureStore.deleteItemAsync(TOKEN_KEY);await FacePing.unpair();
await FacePing.close();
await tokenStore.remove();3. Sync, then check people in#
The SDK syncs when the app starts and then every 5 minutes. Sync yourself to sync now and see what arrived: the result says how many people the device can verify (enrolled) and the sync status. Then, for each person, scan their ID (ticket, membership card or badge) and run a live check against it.
var sync = await faceping.SyncAsync(); // IFacePing, injected
Status.Text = $"{sync.Enrolled} people synced ({sync.Status})";
var result = await faceping.VerifyLiveAsync(scannedId, Camera); // Camera: a FaceCameraView, which shows the prompts
if (result.Outcome == VerifyOutcome.Match) { /* let them in */ }var faceping = IFacePing.Current;
var sync = await faceping.SyncAsync();
Status.Text = $"{sync.Enrolled} people synced ({sync.Status})";
var result = await faceping.VerifyLiveAsync(scannedId, Camera); // Camera: a FaceCameraView
if (result.Outcome == VerifyOutcome.Match) { /* let them in */ }val faceping = FacePing.current
lifecycleScope.launch {
val sync = faceping.sync()
status.text = "${sync.enrolled} people synced (${sync.status})"
}
// For each person (in a coroutine):
val result = faceping.verifyLive(scannedId, camera) // camera: an ai.faceping.FaceCameraView
if (result.outcome == VerifyOutcome.MATCH) { /* let them in */ }guard let faceping = FacePing.shared else { return } // nil if FacePing.configure failed
let sync = try await faceping.sync()
status = "\(sync.enrolled) people synced (\(sync.status))"
// For each person:
let result = try await faceping.verifyLive(id: scannedId, camera: camera) // camera: a FaceCameraView
if result.outcome == .match { /* let them in */ }final faceping = FacePing.current;
final sync = await faceping.sync();
setState(() => status = '${sync.enrolled} people synced (${sync.status.name})');
// For each person:
final result = await faceping.verifyLive(scannedId, camera); // camera: a FacePingCameraController
if (result.outcome == VerifyOutcome.match) { /* let them in */ }const sync = await FacePing.sync();
setStatus(`${sync.enrolled} people synced (${sync.status})`);
// For each person (camera: useRef<FaceCameraRef>, on a <FaceCamera ref={camera}>):
const result = await FacePing.verifyLive(scannedId, camera);
if (result.outcome === 'match') { /* let them in */ }const sync = await FacePing.sync();
status.textContent = `${sync.enrolled} people synced (${sync.status})`;
// For each person (FacePing opens its own camera screen):
const result = await FacePing.verifyLive(scannedId);
if (result.outcome === 'match') { /* let them in */ }Once a device has synced, a sync never throws for a revoked token or a deleted list: its status is revoked (or gone once a list is past its deletion date), and the device wipes its faces. With no connection it's unavailable, and the people synced before keep working until the lease runs out. (A device's very first sync is different: a revoked or mistyped token throws a setup error, so a pairing screen can say so.) Each platform spells these its own way (Revoked in C#, REVOKED in Kotlin, .revoked in Swift, revoked in Dart and TypeScript), and the same goes for the outcomes in the table below.
| Result | What to do |
|---|---|
Match |
Verified: let them in, open the turnstile or record the check-in |
NotEnrolled, LeaseExpired, Expired |
Use your standard (non-face) check-in |
LivenessFailed, ChallengeFailed, NoMatch, NoFace |
Hand over to a member of staff |
Signed results for your server#
On a check-in device, every result is signed by the device: signedResult (SignedResult in C#) is a compact JWS your server can check, so it can rely on a check that happened on a device it can't see (a member check-in, a door, a reward). Pass a nonce from your server to the check to bind the result to it. The device registers its signing key at its first sync, and each sync says whether FacePing holds it (signing: registered, mismatch or unknown). A mismatch means the app was reinstalled or its data cleared: checks still work, but its signed results won't verify until you add the device again, with a new token. The dashboard shows each device's key, and GET /v1/lists/{listId}/devices returns it (keyId, publicKey, keyRegisteredAt, keyMismatchAt). See Signed check results.
Anti-spoofing#
The live check (VerifyLiveAsync, verifyLive) applies FacePing's check-in policy for you:
- Passive liveness on every frame (score ≥ 0.9): one frame that looks like a photo or screen ends the attempt.
- Active liveness: after a live frontal match, the person turns their head in a random direction, then looks back for a second match. Any wrong-way turn fails.
- 10-second window, then hand over to staff.
These defeat photos and screens. A replayed video of the person could beat the head turn; for unattended devices, keep staff in view.
Offline and withdrawal#
- Packs are AES-256-GCM encrypted with a per-list key held in the device keychain/keystore.
- A device that can't reach FacePing keeps working for 24 hours (its lease), then stops verifying until it syncs.
- Revoking a device, deleting the list or suspending your account wipes devices at their next sync.
- At the retention deadline the device deletes the key first, then the data, even offline.
- On an ongoing list, each sync leaves out anyone due for deletion within the next 24 hours, so a device drops a face up to a day before its maximum age and never keeps it past. A device that can't sync for 30 days wipes everything.