Skip to main content
Not sure which Scandit product fits your use case?

Install the Scandit plugin and use the /data-capture-sdk skill so that your AI coding agent can recommend the right product for your use case. More info →

Run the following command in your project directory. It detects the supported coding agents you have installed and adds the Scandit plugin to each. Re-run it to update.

npx plugins add scandit/skills

Prefer to set it up yourself? Manual installation steps for each agent →

Bluetooth Device Pairing

Prerequisites​

Before you begin, ensure you have the following prerequisites:

  • The latest version of Xcode
  • An iOS project with a deployment target of iOS 14.0 or higher
  • A Scandit Express license key. Sign up for a free trial if you don't already have a license key.

Installation​

To integrate the BLEScanner SDK into your Xcode project using Swift Package Manager, add the desired frameworks in the Package Dependencies section of your project.

Add our SPM package repository:

https://github.com/Scandit/blescanner-spm

Alternatively, if you prefer checking out git repositories via SSH:

git@github.com:Scandit/blescanner-spm.git

Configuring the Host​

To use the SDK in your source code, import it as follows:

import BLEScannerSDK

You can then use the WedgeHost initializer to set up a host:

WedgeHost(
hostName: String,
projectCode: String,
baseUrl: String,
eventCallback: (WedgeHostEvent) -> Void
)
  • hostName: The name you specify for the host.
  • projectCode: Your Scandit Express project code provided in the dashboard.
  • baseUrl: The base URL for the QR code that will be generated. You can use this to directly open your app by specifying a universal link. For example, if you want your host to redirect users to Scandit Express, you can specify https://express.scandit.com/bluetooth or scanditExpress://bluetooth.
  • eventCallback: The callback for events sent to the host (more details below).

The host can provide you with the connection QR code as a UIImage using:

host.makeQRCode().generateQRCode()

Receiving Events​

Hosts receive events in the eventCallback. Here's how an event is defined:

public struct WedgeHostEvent {
public let eventType: BLEScannerSDK.WedgeHostEventType
public let data: String?
}
public enum WedgeHostEventType: Int {
case NONE
case ADV_STARTED // ADV stands for advertising Bluetooth services
case ADV_STOPPED
case ADV_ABORTED
case DEVICE_NAME_SET
case DEVICE_BARCODE_RECEIVED
case DEVICE_DISCONNECTED
}

For example, when the host successfully receives a barcode, the WedgeHostEvent will look like this:

WedgeHostEvent(eventType: .DEVICE_BARCODE_RECEIVED, data: "barcode data")

Debugging the Host​

You will need to run the host on a physical device since Bluetooth functionality does not work on the simulator.