Results
Live updates, hints, the final measurement result and error codes of the iOS SDK, as Swift types.
The SDK reports progress through onRealtime and delivers the final result through
onResult. Both carry plain Swift values: RealtimeUpdate and MeasurementResult.
Live updates
onRealtime fires repeatedly while frames arrive: before start() for the pre-check, and
during the measurement.
| Field | Type | Description |
|---|---|---|
heartRate | Int? | Live heart rate, bpm. nil until the reading is stable |
qualityLevel | QualityLevel | Current signal quality: .good, .fair or .poor |
qualityScore | Double | Current signal quality, 0–1 |
elapsedSeconds | Double | Seconds measured so far |
remainingSeconds | Double | Seconds left. Drive a countdown or a progress ring with it |
hint | String? | What the user should fix right now. nil when the frames are usable |
Present the live heart rate as provisional. The final value is in the result.
Hints
Turn hint into a short instruction on screen. Before start(), enable your Start
button once hint is nil.
hint | Meaning | Message (English) | Message (Russian) |
|---|---|---|---|
noFace | No face in the frame | Look at the camera | Смотрите в камеру |
faceTooSmall | The face is too far away | Move closer | Придвиньтесь ближе |
faceTooLarge | The face is too close | Move back a little | Отодвиньтесь немного |
tooDark | Not enough light on the face | Find more light | Нужно больше света |
unstable | The face or the camera is moving | Hold still | Не двигайтесь |
lowSampleRate | Frames arrive too slowly | Camera frame rate is too low | Низкая частота кадров камеры |
lowSnr | The pulse signal is weak | Hold still and keep the light even | Не двигайтесь, свет должен быть ровным |
insufficientMetrics | The measurement needs more clean signal | Keep going | Продолжаем замер |
modelError | The SDK could not process the frames | Something went wrong. Try again | Что-то пошло не так. Попробуйте ещё раз |
lowSampleRate points to your capture setup rather than to the user — see
Troubleshooting. After modelError, call start() to
begin a new measurement.
The result
onResult fires once per measurement with a MeasurementResult. It follows the
measurement result shared by every platform. An iOS result
contains the core metrics — heart rate, HRV with time-domain and Poincaré indices,
breathing rate and stress — plus beta estimates of blood pressure and SpO2.
Summary and quality
| Property | Type | Description |
|---|---|---|
source | String | Always "ios" |
durationSec | Double | Measurement length, seconds |
isComplete | Bool | Whether the measurement ran its full duration |
quality.level | QualityLevel | .good, .fair or .poor |
quality.score | Double | Signal quality, 0–1 |
quality.usable | Bool | false when level is .poor |
Core metrics
| Property | Type | Description |
|---|---|---|
cardiac.heartRate.value | Int? | Heart rate, bpm |
cardiac.heartRate.confidence | Double? | Confidence in the heart rate, 0–1 |
hrv.sdnnMs | Int? | HRV: SDNN, ms |
hrv.rmssdMs | Int? | RMSSD, ms |
hrv.pnn50Pct | Double? | pNN50, % |
hrv.sd1Ms, hrv.sd2Ms | Double? | Poincaré SD1 and SD2, ms |
hrv.sd1Sd2Ratio | Double? | SD1 / SD2 |
hrv.csi, hrv.cvi | Double? | Cardiac sympathetic and cardiac vagal indices |
respiratory.breathingRate.value | Int? | Breathing rate, breaths per minute |
stress.index | Int? | Stress index, 0–100 |
stress.level | StressLevel? | .low, .moderate or .high |
Beta metrics
| Property | Type | Description |
|---|---|---|
bloodPressure.systolicMmHg | Int? | Blood pressure: systolic, mmHg |
bloodPressure.diastolicMmHg | Int? | Diastolic, mmHg |
bloodPressure.mapMmHg | Int? | Mean arterial pressure, mmHg |
bloodPressure.ppMmHg | Int? | Pulse pressure, mmHg |
spo2.value | Int? | SpO2, % |
bloodPressure.tier, spo2.tier | String | Always "beta" |
bloodPressure.disclaimer, spo2.disclaimer | String | Text to show next to the values |
Every metric section also has a unit string: "bpm", "brpm", "index", "mmHg" or
"%".
Show the result
func rows(for result: MeasurementResult) -> [(label: String, value: String)] {
guard result.quality.usable else { return [] }
var rows: [(label: String, value: String)] = []
if let bpm = result.cardiac.heartRate.value {
rows.append((label: "Heart rate", value: "\(bpm) bpm"))
}
if let sdnn = result.hrv.sdnnMs {
rows.append((label: "HRV", value: "\(sdnn) ms"))
}
if let breaths = result.respiratory.breathingRate.value {
rows.append((label: "Breathing rate", value: "\(breaths) /min"))
}
if let stress = result.stress.level {
rows.append((label: "Stress", value: stress.rawValue))
}
if let systolic = result.bloodPressure.systolicMmHg, let diastolic = result.bloodPressure.diastolicMmHg {
rows.append((label: "Blood pressure (beta)", value: "\(systolic)/\(diastolic) mmHg"))
}
if let spo2 = result.spo2.value {
rows.append((label: "SpO2 (beta)", value: "\(spo2) %"))
}
return rows
}- Check
quality.usablefirst. When it isfalse, every metric value isnil. Ask the user to measure again, holding still in even light..fairresults are usable — see Signal quality. - Handle
nilfor each metric. Even with good quality, a single metric can benilwhen it did not collect enough clean signal; HRV and blood pressure need more than heart rate. Hide the field instead of showing0or a placeholder. - Keep beta values visually secondary. Show blood pressure and SpO2 below the core
metrics, with their
disclaimer.
Wellness use only
Blood pressure and SpO2 are beta estimates for wellness use. They are not a medical
device. Show the disclaimer text next to them — see Disclaimer.
Store the result
MeasurementResult is Codable, and JSONEncoder turns it into a valid body for
POST /sdk/v1/measurements: the keys match the API, and
nil values are omitted.
let body = try JSONEncoder().encode(result){
"source": "ios",
"durationSec": 30.1,
"isComplete": true,
"quality": { "level": "good", "score": 0.82, "usable": true },
"cardiac": { "heartRate": { "value": 72, "unit": "bpm", "confidence": 0.88 } },
"hrv": {
"sdnnMs": 48, "rmssdMs": 41, "pnn50Pct": 12.5,
"sd1Ms": 29.1, "sd2Ms": 61.4, "sd1Sd2Ratio": 0.47, "csi": 2.11, "cvi": 3.25
},
"respiratory": { "breathingRate": { "value": 15, "unit": "brpm" } },
"stress": { "index": 34, "level": "moderate", "unit": "index" },
"bloodPressure": {
"systolicMmHg": 118, "diastolicMmHg": 77, "mapMmHg": 91, "ppMmHg": 41,
"unit": "mmHg", "tier": "beta",
"disclaimer": "Estimate for wellness use only. Not a medical device."
},
"spo2": {
"value": 97, "unit": "%", "tier": "beta",
"disclaimer": "Estimate for wellness use only. Not a medical device."
}
}Send this JSON to your backend, add userRef there and store it with a signed request —
see Quickstart. The stored measurement gets an id (meas_…)
and carries origin: "on_device" and attested: false, because the device computed it —
see Attested results. Storing results is free. With a test
key (nk_test_…), stored results are marked test: true.
Errors
MeasurementError has a code and a readable message. Problems with frames never raise
an error: they arrive as hint.
| Code | Where | Meaning | What to do |
|---|---|---|---|
init_failed | Thrown by the initializer | The SDK could not be created | Show an error state instead of the camera. If it repeats on a device, contact support@neccessory.com with the device model and iOS version |
start_failed | onError | The measurement could not start | Let the user try again with start() |
no_secret | Thrown by submit(_:) | The instance was created without secret | Store the result through your backend, or pass secret to the initializer |
submit_failed | Thrown by submit(_:) | No HTTP response from the server | Keep the result and retry later |
"400", "401", "429", … | Thrown by submit(_:) | The server rejected the request; the code is the HTTP status. message carries the server's error message | See Errors. For "401", see Troubleshooting |
submit(_:) can also throw URLError, for example without a network connection, and
EncodingError.