Getting started

Project Configuration

You will need to add the following to your projects Info.plist, replace "Your App" with your app's name, or change the wording as you see fit.

<key>NSBluetoothAlwaysUsageDescription</key>
<string>"Your App" needs Bluetooth enabled to communicate with your Yoco card machine.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>"Your App" needs Bluetooth enabled to communicate with your Yoco card machine.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>"Your App" needs your location for transaction security purposes.</string>
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.miura.shuttle</string>
<string>com.miura.rpi</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>external-accessory</string>
</array>

Initialising the YocoSDK

In order to do a transaction with the YocoSDK, you will need to acquire a secret integration key from Yoco by filling out this Yoco Integrations form. Once filled out, an employee from Yoco will reach out to you with details.

Once you have acquired your secret key, the next step is to call the initialise() function from the YocoSDK. Normally this will go inside your AppDelegate but it can be called any time before trying to interact with any of the other API's of the YocoSDK. initialise() must only be called once per app launch. Following initialise() you will need to call configure() with your secret. Set loggingEnabled to true, to see extra debug logs. Set environment to .production or .staging for production release or test builds. You can call configure multiple times per app run if you wish to change logging output or switch environments.

Please ensure that you also call applicationWillTerminate() in your AppDelegate's applicationWillTerminate callback so that the YocoSDK can clean up appropriately in the event of the app being terminated unexpectedly.

import YocoSDK
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Yoco.initialise()
Yoco.configure(secret: "<your-integration-secret>", loggingEnabled: true, environment: .staging)
return true
}
func applicationWillTerminate(_ application: UIApplication) {
Yoco.applicationWillTerminate()
}
warning

All functions of the YocoSDK must be called on the main thread.

The YocoSDK cannot build for the i386 architecture.

You are now ready to start making a payment!