NeccessoryNeccessory
iOS SDK

Quickstart

Init the SDK with your key, feed camera frames, and read a measurement result.

This walks through a minimal integration: create the SDK with your key, hand it camera frames, and receive a measurement result.

1. Create the SDK

Initialize with your key — a key id and secret:

import NeccessorySDK

let sdk = try NeccessorySDK(keyId: "nk_live_sRwG9z2hK2hdV4Il83J7Cw", secret: mySecret)

Creating the SDK compiles the on-device model and blocks for a few seconds — do it on a background queue, not on the main thread, or the first camera frame will stall. Callbacks are delivered on the main thread.

Everything runs on-device in this SDK. The key attributes measurements to your account and authenticates any API calls. The cloud tier, which computes the metrics on our servers and transmits face crops to do it, is a different integration.

2. Receive callbacks

sdk.onRealtime = { update in
    // Live during capture: heart rate, quality and a coaching hint.
    if let hr = update.heartRate { updateLiveHeartRate(hr) }
    updateQualityIndicator(update.qualityLevel)   // .good | .fair | .poor
}

sdk.onResult = { result in
    // Called once, on completion — the full measurement result.
    presentResult(result)   // see the measurement-result reference
}

sdk.onError = { error in
    // { code, message } — no internal details.
    showError(error.message)
}

3. Start and feed camera frames

Start the measurement, then hand the SDK each camera frame you capture (for example from an AVCaptureVideoDataOutputSampleBufferDelegate):

sdk.start()

func captureOutput(
    _ output: AVCaptureOutput,
    didOutput sampleBuffer: CMSampleBuffer,
    from connection: AVCaptureConnection
) {
    guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
    let ts = CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer))
    sdk.processFrame(pixelBuffer: pixelBuffer, timestampSeconds: ts)
}

Keep a face in view and hold still. A live heart rate appears within about 10 seconds via onRealtime; the full measurement completes in roughly 30–35 seconds and delivers the result via onResult.

4. Stop or reset

sdk.stop()    // stop the current measurement

The result

onResult delivers exactly the measurement result: quality (required), the Core sections (cardiac, hrv, respiratory, stress), and the Beta sections (bloodPressure, spo2), each clearly labeled wellness-only.

Next: Results reference.