Methods
Reference for all public methods on the CircadifySDK instance.
measureVitals(options:)
Section titled “measureVitals(options:)”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}SwiftUI Usage
Section titled “SwiftUI Usage”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)") } }}UIKit Usage
Section titled “UIKit Usage”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 } } } }}checkCameraPermission()
Section titled “checkCameraPermission()”Returns the current camera authorization status without prompting the user.
let status = sdk.checkCameraPermission()
switch status {case .authorized: // Ready to scancase .notDetermined: // Need to request permissioncase .denied, .restricted: // Cannot scan — guide user to Settings@unknown default: break}Returns: AVAuthorizationStatus
requestCameraPermission()
Section titled “requestCameraPermission()”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: Bool — true if permission was granted.
cancel()
Section titled “cancel()”Cancels a measurement in progress. The measureVitals() call will throw CircadifyError.cancelled.
// Start measurement in a tasklet task = Task { try await sdk.measureVitals()}
// Cancel from elsewhere (e.g., a button tap)sdk.cancel()
// The task will throw CircadifyError.cancelleddo { let result = try await task.value} catch let error as CircadifyError where error == .cancelled { print("Scan cancelled by user")}Next Steps
Section titled “Next Steps”- Configuration — Callbacks and options
- Camera & Permissions — Permission handling in depth
- Error Handling — Handle all failure cases