FingerprintJS Pro iOS Integrations
An example app and packages demonstrating FingerprintJS Pro capabilities on the iOS platform. The repository illustrates how to retrieve a FingerprintJS Pro visitor identifier in a native mobile app. These integrations communicate with the FingerprintJS Pro API and require browser token. If you are interested in the Android platform, you can also check our FingerprintJS Pro Android integrations.
There are two typical use cases:
- Using our native library to retrieve a FingerprintJS Pro visitor identifier in the native code OR
- Retrieving visitor identifier using signals from the FingerprintJS Pro browser agent in the webview on the JavaScript level combined with vendor identifier.
This integration approach uses our library fpjs-ios-wv. It collects various signals from the iOS system, sends them to the FingerprintJS Pro API for processing, and retrieves an accurate visitor identifier.
Specify the following dependency in your Podfile
:
pod 'FingerprintJSPro', '~> 0.1.1'
Add the following dependency to your Package.swift
.
dependencies: [
.package(url: "https://github.com/fingerprintjs/fingerprintjs-pro-ios-integrations", .upToNextMajor(from: "0.1.0"))
]
import FingerprintJSPro
You can find your browser api token in your dashboard.
FingerprintJSPro.Factory
.getInstance(
token: "your-browser-token", // required
endpoint: URL(string: "https://fp.yourdomain.com"), // default: nil, optional: true
region: nil // default: nil, optional: true ("eu" for europe, nil for global)
)
.getVisitorId { result in
switch result {
case let .failure(error):
print("Error: ", error.localizedDescription)
case let .success(visitorId):
print("Success: ", visitorId)
}
}
This approach uses signals from FingerprintJS Pro browser agent together with iOS device vendor identifier. The vendor identifier is added to the tag
field in the given format. FingerprintJS Pro browser agent adds an additional set of signals and sents them to the FingerprintJS Pro API. Eventually, the API returns accurate visitor identifier.
let vendorId = UIDevice.current.identifierForVendor?.uuidString ?? "undefined"
let script = WKUserScript(source: "window.fingerprintjs.vendorId = \(vendorId)",
injectionTime: .atDocumentStart,
forMainFrameOnly: false)
webView.configuration.userContentController.addUserScript(script)
function initFingerprintJS() {
// Initialize an agent at application startup.
const fpPromise = FingerprintJS.load({
token: "your-browser-token",
endpoint: "your-endpoint", // optional
region: "your-region", // optional
});
// Get the visitor identifier when you need it.
fpPromise
.then((fp) =>
fp.get({
tag: {
deviceId: window.fingerprintjs.vendorId, // use vendor ID as device ID
deviceType: "ios",
},
})
)
.then((result) => console.log(result.visitorId));
}
You can find your browser token in your dashboard.
FingerprintJS Pro documentation
This library is MIT licensed.