Skip to main content

Quickstart

Stream your first biosignal from a BLE wearable in under 5 minutes.

1. Install the SDK

Add the binary Swift package in Xcode:

  1. File > Add Package Dependencies...
  2. Enter: https://github.com/anybio/biosdk-ios-binary.git
  3. Add the BioSDK product to your app target

See the full Installation guide for details.

2. Configure the SDK

import BioSDK

// Initialize with your project credentials
let config = BioSDKClient.Configuration(
environment: .auto,
organizationKey: "org_your_key",
projectKey: "proj_your_key"
)

let sdk = try await BioSDKClient.initialize(configuration: config)

3. Subscribe to Events

import Combine

var cancellables = Set<AnyCancellable>()

sdk.events
.sink { event in
switch event {
case .lifecycle(let lifecycle):
switch lifecycle {
case .discovered(let device):
print("Found: \(device.name)")
case .connected(let device):
print("Connected: \(device.name)")
case .disconnected(let device, _, _, _):
print("Disconnected: \(device.name)")
}

case .sample(let deviceId, let sample):
print("[\(deviceId)] \(sample.signalName): \(sample.data)")

case .deviceState(let device, let connection, let stream):
print("\(device.name): \(connection) / \(stream)")

case .session(let sessionEvent):
print("Session: \(sessionEvent)")

case .notification:
break
}
}
.store(in: &cancellables)

4. Scan and Connect

// Start scanning for BLE devices
sdk.startScan()

// When you find your device (e.g., from a UI list):
let device = sdk.discoveredDevices.first!
sdk.connect(device)

5. Start Streaming

Once the device reaches .ready connection state:

sdk.startStreaming(deviceId: device.id)

Biosignal samples will flow through the events publisher as .sample events.

6. Stop and Disconnect

sdk.stopStreaming(deviceId: device.id)
sdk.disconnect(device)

What's Next