@neurofit/vitals-capacitor is a Capacitor 6 plugin: a CAPPlugin on iOS and a Plugin on Android forward
every call to the native NeurofitVitals (Swift) or com.neurofit.vitals (Kotlin) SDK. The web implementation
is a stub whose methods reject with Capacitor’s own ExceptionCode.Unavailable (the code string UNAVAILABLE),
so your web build compiles and you can feature-detect at runtime. Event names and payload keys are the same as the React Native and Flutter wrappers.
1
Install the plugin
The plugin is delivered with your license.The podspec links
NeurofitVitals.xcframework from the plugin’s ios/Frameworks/ folder (binary license) or
the Swift package sources (source license). The Android module depends on com.neurofit:vitals-sdk:1.0.0;
make that artifact resolvable from mavenLocal() or your artifact repository, and set minSdkVersion to 28
or higher in variables.gradle.2
Platform setup
iOS: add
NSCameraUsageDescription to ios/App/App/Info.plist (see the iOS quickstart).
Adding NSMotionUsageDescription as well is recommended while motionBreathing is on.Android: the plugin’s manifest declares android.permission.CAMERA, so nothing to add. See the
Android quickstart for the optional uses-feature entries.3
Activate and check the device
Plugin methods take a single options object and resolve to an object.Rejections carry
code (the native error case: licenseInvalid, licenseNotValidForApp,
licenseUpdatesExpired, cameraDenied, …) and message. See License keys.4
Run a reading
createSession returns a sessionId. Add listeners before calling start; the plugin does not buffer
events. Every payload carries event and sessionId.NeurofitVitals.cancelReading({ sessionId, reason: 'user_tapped_cancel' }) cancels the current attempt while
measuring (the session returns to positioning; ignored while positioning). stop({ sessionId }) tears the
camera down and releases the handle; it is idempotent, so a second stop resolves. A later start or
cancelReading with a released handle rejects with the wrapper-level code sessionNotFound.
removeAllListeners() clears every listener at once when your reading screen is destroyed.start rejects with the native error (notActivated, alreadyRunning, cameraDenied, cameraRestricted,
unsupportedDevice, on iOS also cameraUnavailable); on Android a camera that cannot be opened arrives
afterwards as a failed event with code cameraUnavailable.Foreground, orientation and screen
A reading needs the app in the foreground for the whole minute: backgrounding (iOS) or the host activity’sON_STOP (Android) during positioning or measuring ends the session with a failed event whose error.code is
interrupted. Lock the reading screen’s orientation while a session runs (@capacitor/screen-orientation) and
keep the screen awake (@capacitor-community/keep-awake).
Plugin interface
definitions.ts
LicenseStatus, DeviceSupport, VitalsConfiguration, LivePreview, VitalsResult, VitalsError, the
event payload interfaces and the VitalsEvent union) are exported from the package and match the
React Native shapes exactly. On the web, rejections carry
Capacitor’s ExceptionCode.Unavailable (UNAVAILABLE) rather than a native case name.
Camera preview
The camera preview is optional on every platform: a fingertip covers the lens during a reading. The V1 plugin does not render it; show the guidance text and the live values in your web UI. A preview view is planned; see Roadmap.Next steps
- Reading lifecycle: what each event means and when it fires.
- Metrics: field definitions, units and validated accuracy.
- Troubleshooting: permission, torch and frame-rate issues.