Skip to content

Methods

Reference for all public methods on the CircadifySDK instance.

Runs the full measurement pipeline: camera access, face detection, frame capture, upload, and server-side inference. Returns vital signs when complete.

let result = try await sdk.measureVitals()

With demographics for improved accuracy:

let result = try await sdk.measureVitals(
options: MeasurementOptions(
demographics: Demographics(age: 35, sex: .male, fitzpatrick: 3)
)
)

Returns: VitalSignsResult

public struct VitalSignsResult: Codable, Equatable {
public let heartRate: Int // BPM
public let hrv: Double? // Heart rate variability (ms)
public let respiratoryRate: Int? // Breaths per minute
public let spo2: Double? // Blood oxygen saturation (%)
public let systolicBp: Int? // Systolic blood pressure (mmHg)
public let diastolicBp: Int? // Diastolic blood pressure (mmHg)
public let confidence: Double // 0-1 reliability score
public let sessionId: String
public let timestamp: Date
}
struct ScanView: View {
@State private var result: VitalSignsResult?
@State private var isScanning = false
let sdk = try! CircadifySDK(apiKey: "ck_test_your_key_here")
var body: some View {
VStack {
if let result {
Text("Heart Rate: \(result.heartRate) BPM")
Text("Confidence: \(String(format: "%.0f%%", result.confidence * 100))")
}
Button(isScanning ? "Scanning..." : "Start Scan") {
Task { await scan() }
}
.disabled(isScanning)
}
}
func scan() async {
isScanning = true
defer { isScanning = false }
do {
result = try await sdk.measureVitals()
} catch {
print("Scan failed: \(error)")
}
}
}
class ScanViewController: UIViewController {
let sdk = try! CircadifySDK(apiKey: "ck_test_your_key_here")
@IBAction func startScan(_ sender: UIButton) {
sender.isEnabled = false
Task {
do {
let result = try await sdk.measureVitals()
DispatchQueue.main.async {
self.displayResults(result)
sender.isEnabled = true
}
} catch {
DispatchQueue.main.async {
self.showError(error)
sender.isEnabled = true
}
}
}
}
}

Returns the current camera authorization status without prompting the user.

let status = sdk.checkCameraPermission()
switch status {
case .authorized:
// Ready to scan
case .notDetermined:
// Need to request permission
case .denied, .restricted:
// Cannot scan — guide user to Settings
@unknown default:
break
}

Returns: AVAuthorizationStatus

Requests camera permission from the user. Shows the system permission dialog if status is .notDetermined.

let granted = await sdk.requestCameraPermission()
if granted {
let result = try await sdk.measureVitals()
} else {
// Handle denial
}

Returns: Booltrue if permission was granted.

Cancels a measurement in progress. The measureVitals() call will throw CircadifyError.cancelled.

// Start measurement in a task
let task = Task {
try await sdk.measureVitals()
}
// Cancel from elsewhere (e.g., a button tap)
sdk.cancel()
// The task will throw CircadifyError.cancelled
do {
let result = try await task.value
} catch let error as CircadifyError where error == .cancelled {
print("Scan cancelled by user")
}