Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



41 Commits

Repository files navigation

Clover logo

Clover SDK for iOS Integration

A Swift implementation of the CloverConnector to enable iOS and MacOS to communicate with a tethered Clover Mini or Flex.


Current version: 4.0.0


  • ObjectMapper - Provides JSON serialization and deserialization.
  • SwiftyJSON - Provides simple JSON parsing.
  • Starscream - provides websocket client capabilities. NOTE: we have forked this and made some small tweaks that improve large-file handling, so be sure to point to our fork (example below).

Example Implementation

This SDK is provided with an example implementation available at

Using CloverConnector in your project

platform :ios, '9.0'


target 'RegisterApp' do

    # The queuePriority branch of our fork of the Starscream framework is required for reliable transport of large files
    # Defining it here in the PodFile overrides the podspec dependency, which isn't allowed to specify a specific location and branch
    pod 'Starscream', :git => '', :branch => 'queuePriority-3.0.0'

    pod 'CloverConnector', :git => '', :tag => '4.0.0'

    post_install do |installer|
        ['CloverConnector'].each do |targetName|
            targets = { |target| == targetName }
            target = targets[0]
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '5.3'

Sample code using CloverConnector

import CloverConnector

class ConnectionManager : DefaultCloverConnectorListener, PairingDeviceConfiguration {
    var cc:ICloverConnector?

    func connect() {
        // load from previous pairing, or nil will force/require
        // a new pairing with the device
        let savedAuthToken = loadAuthToken()

        let config = WebSocketDeviceConfiguration(endpoint: "wss://",
            remoteApplicationID: "",
            posName: "RegisterApp", posSerial: "ABC-123",
            pairingAuthToken: savedAuthToken, pairingDeviceConfiguration: self)

        cc = CloverConnectorFactory.createICloverConnector(config)

    func doSale() {
        // if onDeviceReady has been called
        let saleRequest = SaleRequest(amount: 1743, externalId: "bc54de43f3")
        // configure other properties of SaleRequest

    // store the token to be loaded later by loadAuthToken
    func saveAuthToken(token:String) {}
    func loadAuthToken() -> String? { return nil }

    // PairingDeviceConfiguration
    func onPairingCode(pairingCode: String) {
        // display pairingCode to user, to be entered on the Clover Mini

    func onPairingSuccess(authToken: String) {
        // pairing is successful
        // save this authToken to pass in to the config for future connections
        // so pairing will happen automatically

    // DefaultCloverConnectorListener

    // called when device is disconnected
    override func onDeviceDisconnected() {}

    // called when device is connected, but not ready for requests
    override func onDeviceConnected() {}

    // called when device is ready to take requests. Note: May be called more than once
    override func onDeviceReady(info:MerchantInfo){}

    // required if Mini wants the POS to verify a signature
    override func onVerifySignatureRequest(signatureVerifyRequest: VerifySignatureRequest) {
        //present signature to user, then
        // acceptSignature(...) or rejectSignature(...)

    // required if Mini wants the POS to verify a payment
    override func onConfirmPaymentRequest(request: ConfirmPaymentRequest) {
        //present 1 or more challenges to user, then
        // or
        // cc?.rejectPayment(...)

    // override other callback methods
    override func onSaleResponse(response:SaleResponse) {
        if response.success {
            // sale successful and payment is in the response (response.payment)
        } else {
            // sale failed or was canceled

    override func onAuthResponse(response:AuthResponse) {}
    override func onPreAuthResponse(response:PreAuthResponse) {}

    // will provide UI information about the activity on the Mini,
    // and may provide input options for the POS to select some
    // options on behalf of the customer
    override func onDeviceActivityStart(deviceEvent:CloverDeviceEvent){} // see CloverConnectorListener.swift for example of calling invokeInputOption from this callback
    override func onDeviceActivityEnd(deviceEvent:CloverDeviceEvent){}
    // etc.

Additional Resources


Copyright © 2020 Clover Network, Inc. All rights reserved.