Access barometer pressure measurements across iOS and Android.
The most complete doc is available here: https://capgo.app/docs/plugins/barometer/
npm install @capgo/capacitor-barometer
npx cap syncgetMeasurement()isAvailable()startMeasurementUpdates()stopMeasurementUpdates()checkPermissions()requestPermissions()addListener('measurement', ...)removeAllListeners()getPluginVersion()- Interfaces
- Type Aliases
Capacitor plugin contract for working with the device barometer sensor.
getMeasurement() => Promise<GetMeasurementResult>Get the most recent barometer reading captured by the native layer.
Returns: Promise<Measurement>
Since: 1.0.0
isAvailable() => Promise<IsAvailableResult>Check if the current device includes a barometer sensor.
Returns: Promise<IsAvailableResult>
Since: 1.0.0
startMeasurementUpdates() => Promise<void>Begin streaming barometer updates to the JavaScript layer.
Call {@link addListener} with the measurement event to receive the updates.
Since: 1.0.0
stopMeasurementUpdates() => Promise<void>Stop the continuous updates started via {@link startMeasurementUpdates}.
Since: 1.0.0
checkPermissions() => Promise<PermissionStatus>Return the current permission state for accessing barometer data.
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions() => Promise<PermissionStatus>Request permission to access barometer data if required by the platform.
Returns: Promise<PermissionStatus>
Since: 1.0.0
addListener(eventName: 'measurement', listenerFunc: (event: MeasurementEvent) => void) => Promise<PluginListenerHandle>Listen for pressure updates.
| Param | Type | Description |
|---|---|---|
eventName |
'measurement' |
Only the measurement event is supported. |
listenerFunc |
(event: Measurement) => void |
Callback invoked with each measurement. |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
removeAllListeners() => Promise<void>Remove all registered listeners for this plugin.
Since: 1.0.0
getPluginVersion() => Promise<{ version: string; }>Get the native Capacitor plugin version.
Returns: Promise<{ version: string; }>
Since: 1.0.0
Air pressure and relative altitude values sampled from the device barometer.
| Prop | Type | Description | Since |
|---|---|---|---|
pressure |
number |
The static air pressure in hectopascals (hPa). | 1.0.0 |
relativeAltitude |
number |
The change in altitude relative to the time updates started. Only available on iOS; Android will always return 0. |
1.0.0 |
timestamp |
number |
The timestamp of the measurement in milliseconds since the Unix epoch. | 1.0.0 |
Result returned by {@link CapacitorBarometerPlugin.isAvailable}.
| Prop | Type | Description | Since |
|---|---|---|---|
isAvailable |
boolean |
Indicates whether the device exposes a barometer sensor. | 1.0.0 |
Permission information returned by {@link CapacitorBarometerPlugin.checkPermissions} and {@link CapacitorBarometerPlugin.requestPermissions}.
| Prop | Type | Description | Since |
|---|---|---|---|
barometer |
BarometerPermissionState |
The permission state for accessing barometer measurements on the current platform. | 1.0.0 |
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
Alias for the most recent pressure sample.
Permission state union including limited for platforms that can throttle sensor access.
PermissionState | 'limited'
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
Event payload emitted when {@link CapacitorBarometerPlugin.startMeasurementUpdates} is active.
This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader
