Overview
In this quickstart, you’ll add Fingerprint to a new Xcode iOS app and identify the user’s device. The example use case we’ll use for this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you’ll follow apply to most use cases. By identifying the device behind each sign-up attempt, login, or transaction, you can flag and block suspicious users early. This guide focuses on the front-end mobile integration. You’ll install the Fingerprint iOS SDK and initialize the client to generate a request ID to send to your back end for analysis. To see how to implement fraud prevention with this ID, continue to one of our back-end quickstarts after completing this quickstart.Estimated time: < 10 minutes
Prerequisites
Before you begin, make sure you have the following:- Xcode installed (latest version)
- Basic knowledge of Swift and iOS development
- A Fingerprint account and public API key (see below)
This quickstart only covers the front-end setup. You’ll need a back-end
server to receive and process the device
identification event to enable fraud detection. Check out one of our back-end
quickstarts after completing this
quickstart.
1. Create a Fingerprint account and get your API key
- Sign up for a free Fingerprint trial if you don’t already have an account.
- After signing in, go to the API keys page in the dashboard.
- Copy your public API key; you’ll need it to initialize the Fingerprint client agent.
2. Set up your project
To get started, create a new Xcode project. If you already have a project you want to use, you can skip to the next section.- Open Xcode and create a new project.
- Click on iOS and select App, then click Next.
- Enter a name (e.g.,
FingerprintQuickstart), and an organization identifier (e.g.,com.example), and make sure to use Swift and SwiftUI. - Click Next, choose a save location, and create the project.
3. Install the Fingerprint SDK
To integrate Fingerprint into your iOS app, add the package to your project.- In Xcode, go to File > Add Package Dependencies…
- Enter the package URL:
https://github.com/fingerprintjs/fingerprintjs-pro-ios - Choose the latest version and click Add Package.
- In the Choose Package Products pop-up, make sure to check your app target (e.g.,
FingerprintQuickstart) under “Add to Target” so the SDK is properly linked.
4. Initialize the SDK
Open yourContentView.swift or app entry point and:
- Import the SDK:
ContentView.swift
- Initialize the SDK with your public API key and region:
ContentView.swift
- Replace
<your-public-api-key>with your actual public API key from the Fingerprint dashboard. Use .global, .eu, or .ap based on your workspace region. See region guide.
5. Trigger visitor identification
Now that the Fingerprint client is initialized, you can identify the visitor when needed. In this case, that’s when the user taps a Create Account button. When making the visitor identification request, you will receive thevisitorId as well as a requestId. Instead of using the visitorId returned directly on the front end (which could be tampered with), you’ll send the requestId to your back end. This ID is unique to each identification event. Your server can then use the Fingerprint Events API to retrieve complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.
Add a basic sign-up UI
- Create a new SwiftUI function for the account creation screen. It will display a simple form with username and password fields, along with a Create Account button:
ContentView.swift
- In the ContentView struct; just before the
bodyvariable; add thecreateAccount()function that would be triggered when the Create Account button is clicked:
ContentView.swift
- Update the body variable of the ContentView struct with the AccountCreationForm function:
ContentView.swift
- Displays a basic form for account creation.
- Calls
getVisitorIdResponse()to identify the visitor. - Captures the
requestId, which you’ll forward to your server for analysis.
6. Run the app
- Select an iOS simulator or real device in Xcode.
- Build and run the app (⌘R).
- Enter a username and password then click Create Account.
- Check your Xcode console for something like:
Output
Next steps
To use the identification data for fraud detection (like blocking repeat fake account creation attempts), you’ll need to send therequestId to your back end. From there, your server can call the Fingerprint Events API to retrieve the full visitor information and make decisions.
Check out these related resources: