iOS SDK installation and configuration

The Zettle Payment SDK for iOS lets you accept card payments from any iOS app, using a Zettle card reader. The following describes how to install, configure and initialize the SDK.

Prerequisites

  • Xcode 11+
  • ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES flag is required if your project doesn't include Swift
  • iOS 12 and higher
  • Client ID from the Zettle Developer Portal, see Get started.

Note: Support for iOS 10 and 11 was dropped with version 3.4.0 of the iOS SDK.

Install the SDK

You can install Zettle SDK using CocoaPods, or manually as described in the following.

CocoaPods

CocoaPods is an easy way to install Zettle SDK.

Add following pod to your Podfile:

1
platform :ios, '12.0'
2
target 'Your App' do
3
pod 'iZettleSDK'
4
end

Manual installation

Drag the binary frameworks from the iZettleSDK folder into your Xcode project:

iZettleSDK.xcframework
iZettlePayments.xcframework

Configure the SDK

To be able to use the SDK you must first add configurations as described in the following.

Note: An exception will be thrown if these configurations are not done.

1. Set up external accessory communication background mode

1.1 Xcode modifications

Xcode 11

Select the following background modes to enable support for external accessory communication. You can find them under Signing & Capabilities in your target.

  • External accessory communication
  • Uses Bluetooth LE accessory

Earlier Xcode versions

In your Xcode project, select the Capabilities tab. Go to the Background modes section to enable external accessory communication support.

1.2 Info.plist modifications

Edit your Info.plist file to have the following information set:

1
<key>UIBackgroundModes</key>
2
<array>
3
<string>bluetooth-central</string>
4
<string>external-accessory</string>
5
</array>
6
7
<key>NSBluetoothAlwaysUsageDescription</key>
8
<string>Our app uses bluetooth to find, connect and transfer data with Zettle card reader devices.</string>
9
10
<key>NSBluetoothPeripheralUsageDescription</key>
11
<string>Our app uses bluetooth to find, connect and transfer data with Zettle card reader devices.</string>
12
13
<key>CFBundleURLTypes</key>
14
<array>
15
<dict>
16
<key>CFBundleTypeRole</key>
17
<string>Editor</string>
18
<key>CFBundleURLSchemes</key>
19
<array>
20
<string>"The scheme of your OAuth Redirect URI *"</string>
21
</array>
22
</dict>
23
</array>

Note: Zettle will ask the user for permission to allow your app access to Blutooth capabilities. Doing so, the texts for NSLocationWhenInUseUsageDescription and NSBluetoothPeripheralUsageDescription keys are displayed. You may want to update these texts to your requirements.

If you don't remember the scheme of your OAuth Redirect URI, you can verify it on the Developer Portal.

2. Set up CLLocationManager

The merchant must grant your app this permission. If not done, Zettle will prompt the user for permission during the first payment and execute the CLLocationManagers method requestWhenInUseAuthorization.

Add the key in your Info.plist:

1
<key>NSLocationWhenInUseUsageDescription</key>
2
<string>You need to allow this to be able to accept card payments</string>

Zettle won't accept payments without these texts implemented.

3. Import the SDK framework

Make sure to include the Zettle SDK framework:

Objective C:

1
@import iZettleSDK;

Swift:

1
import iZettleSDK

4. Set up external accessory protocols

Note: If you are using Zettle Reader 1 then this step is needed, otherwise you can skip this.

In your Info.plist, add/modify the property Supported external accessory protocols and add com.izettle.cardreader-one.

Your Info.plist file should look somethng like this in the "source code" view:

1
<key>UISupportedExternalAccessoryProtocols</key>
2
<array>
3
<string>com.izettle.cardreader-one</string>
4
</array>

Important: The Zettle Bluetooth card readers are part of the Apple MFi program. In order to release apps supporting accessories that are part of the MFi Program, you have to apply at Apple. Please contact our Integrations team and we will help you with this process.