- Include the SDK in your iOS apps.
- Get a
visitorId. - Read the SDK response.
- Enable location data collection (optional; to start getting additional location-based proximity data).
- Configure the SDK as per your needs.
- Specify additional metadata in your identification request.
- Handle errors.
Prerequisites
- Sign up for an account with Fingerprint to get your API key.
- Xcode 15.0 or higher. See App Store submission requirements for more information.
Including the SDK in your app
Add the SDK as a dependency.SPM
CocoaPods
Getting a visitorId
To get a visitorId, you need the public API key that you obtained when signing up for an account with Fingerprint. You can find this API key in the Dashboard > API Keys.
Here is an example that shows you how to get a visitorId:
Swift
Specifying a custom timeout
Default timeout value: 60 seconds You can override the default timeout with a custom value of your choice. If thegetVisitorId() call does not complete within the specified (or default) timeout, you will receive a FPJSError.clientTimeout error.
Here is an example that shows you how to specify a custom timeout:
Swift
Reading the response
The functionFingerprintClientProviding.getVisitorIdResponse() returns the response in a FingerprintResponse object.
Swift
| Field | Sealed Client Results is disabled | Sealed Client Results is enabled |
|---|---|---|
version | String. The API version. | String. The API version. |
requestId | String. An identifier that uniquely identifies the request associated with the API call. | String. An identifier that uniquely identifies the request associated with the API call. |
visitorId | String. An identifier that uniquely identifies the device. | N/A |
confidence | Float. A score that indicates the probability of this device being accurately identified. The value ranges from 0.0 to 1.0. | N/A |
visitorFound | Bool. Indicates if a device has already been encountered by your app. | N/A |
sealedResult | nil | String?. An encrypted, binary, Base64-encoded String that contains the same response as you would receive with an /events API request. |
Using Location Data for Proximity Detection
This is optional. Enable this only if you want to include the additional location-based proximity detection signal in your response.
false. To start getting Proximity ID and related data, set this property to true in your SDK configuration.
Important note: For the best location precision, we recommend initializing the Fingerprint client as early as possible - ideally during your app startup - and maintaining the same instance throughout the app’s lifecycle.
Swift
Handling Location Permissions
Your app is responsible for asking for location permissions. Refer to Apple documentation or check the Fingerprint demo app if you need to implement this flow. If you already have this process set up, skip to the next section. If your app doesn’t currently implement a flow for requesting and managing location permissions, we’ve included a utility to help simplify this process. TheLocationPermissionHelper is designed to assist host apps with requesting, observing, and responding to user location permission changes.
It leverages a LocationPermissionDelegate to notify the host app whenever the authorization status is updated. This simplifies the integration process without needing to build a full permission handling flow from scratch.
Here is an example that shows how to create a location permission helper:
Swift
Info.plist as it is required for App Store submission:
NSLocationWhenInUseUsageDescription- required; for general system request when asking for location access.NSLocationTemporaryUsageDescriptionDictionarywithProximityIDpurpose key - optional; for general system request when asking for temporary precise location in case the user has a setting that hides accurate location.NSLocationAlwaysAndWhenInUseUsageDescription- optional, only if your app requires checking location in background mode; for general system request when asking to always have access to the user’s location (including background). It will also requireUIBackgroundModesto havelocationinInfo.plistto access the user’s location in the background.- Request permission in your app’s code
- Call
requestPermission()orrequestPrecisePermission()from the SDK, depending on the level of access needed. - Or use your own location permission flow.
- Call
- Show rationale UI (optional)
- You may present your own UI to explain why location is needed.
Configuring the SDK
Using the Configuration object, it is possible to configure the SDK as per your requirements. As of now, the following options are supported:region
Type: Region.
Default value: Region.global
This option allows you to specify a region where you want your data to be stored and processed. This region must be the same as the one you specified when registering your app with Fingerprint. Use Region.custom(domain:fallback:) enumeration case to specify a custom endpoint, particularly when you have set up either a custom sub-domain or a proxy integration. See region for more information.
extendedResponseFormat
Type: Bool
Default value: false
When set to true, in addition to those fields returned by default, the FingerprintResponse object will also contain the following fields:
ipAddress- String. The IPv4 address of the device.ipLocation- IPLocation. [This field is deprecated and will not return a result for applications created after January 23rd, 2024. See IP Geolocation for a replacement available in our Smart Signals product.] Indicates the location as deduced from the IP address.firstSeenAt,lastSeenAt- Timestamp. See Visitor Footprint Timestamps.
allowUseOfLocationData
Type: Bool
Default value: false
This option allows you to enable the location data collection needed to calculate the location-based proximity detection signal.
Specifying linkedId and tag
Like the JS Agent, the iOS SDK also supports providing custom metadata with your identification request. To learn more about this capability, please visit Linking and tagging information.
Here is an example that shows you how to associate your identification request with an account ID and additional metadata:
Swift
linkedId and tag on the server.
Handling errors
The SDK provides a FPJSError enumeration that helps you identify the reasons behind an unsuccessful identification request. Here is an example that shows you how to handle errors in your app:Swift
Data Classes
Configuration
Swift
Error
Swift
IPLocation
Swift
Region
Swift