Adding the Fidel iOS SDK to Your Swift iOS Application

Receiving real-time transactions from your custoners will give you unparalleled insight into your users and how they shop at your locations. Fidel's card linking API is the key tool that allows you to receive notifictaions of when and where your customers are shopping at your stores (as well has how much they are spending!).

In order to receive these transactions, your custoners must opt-in with their card numbers. To simplify the opt-in process, Fidel has PCI compliant SDKs for the web, Android and iOS - that accept the card numbers in a way that you never have to handle the card numbers, obsolving you of an secuirty concerns in handling senstivive financial information.

In this post, we'll walk through the steps in creating an iOS app using Swift, and adding in the Fidel SDK. We'll then successfully use the SDK to add a card to our program.

Creating a Swift app

Open Xcode, and create a new Project. Choose a "Single View App":


Next, name your app (I chose FidelSDKApp). We'll use a storyboard layout. A few more clicks, and your app is created in Xcode.

Importing Fidel

Now we must import the Fidel Cocoapod into the app. In the terminal, navigate to the folder of your project and add Cocoapods:

pod init

This will create a Podfile in your directory. Edit this file to add pod 'Fidel' on line 8


To update your app type pod update in your terminal.

Camera Permissions

The SDK has an OCR tool that can read the card numbers using the camera. To enable this, you should edit the info.plist with NSCameraUsageDescription and the value describing "used to scan credit cards."


Adding the Fidel View

We're now ready to add the Fidel SDK view in our app. In ViewController.swift:

import Fidel

Next, we want this to appear on app startup, so add:

    override func viewDidAppear(_ animated: Bool) {

The code we are adding will initialise the Fidel SDK. Let's start with our Fidel Key, and the programId of the program that the cards will be affiliated with:

	Fidel.apiKey     = "pk_test_0367fe38-cdc7-41a2-9d4c-74a1854c171e"
	Fidel.programId = "b4b6d68f-a05a-4cc5-8b9f-f6e82cd988d0"

NOTE: For all Fidel SDKs, you use your public key and not your secret key.

Now we want to add the company name, Privacy URL, deletion instructions and location:

        Fidel.companyName = "Rick Astley's Greatest Hits" // default: "Company Name".
        Fidel.privacyURL = "" 
		      //we're never gonna let you down. (give you up, run around and desert you, etc.)
        Fidel.deleteInstructions = "Your delete instructions" // Maximum 60 characters, default: "going to your account settings." = .unitedKingdom

Before you click the privacy url, make sure you read the comments (you have been warned).

Finally, to allow the SDK view to appear, you must add the following:

        Fidel.present(self, onCardLinkedCallback: { (card: LinkResult) in
        }, onCardLinkFailedCallback: { (err: LinkError) in

In order for my build to complete, I had to remove the Fidel Frameworks from the build.

Running my App

Now I can build and run my application in the emulator. It compiles, and I see the Fidel SDk pop into view. I add a test card number:


When I press "done", I then go to the Fidel dashboard, and I can see that the card was added!


Of course, you can also click the privacy policy link in the app... but don't say I did not warn you.


Adding the Fidel SDk to your Swift iOS app is really easy, and allows your customers to quickly enter their card details into real-time transaction programs. Try it out in your Swift app. If you have any questions, reach out on our community page, or file an issue on the Github repo.