Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-barometer`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/barometer/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled āInstallābun add @capgo/capacitor-barometerbunx cap syncimport { CapacitorBarometer } from '@capgo/capacitor-barometer';API Overview
Section titled āAPI OverviewāgetMeasurement
Section titled āgetMeasurementāGet the most recent barometer reading captured by the native layer.
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.getMeasurement();isAvailable
Section titled āisAvailableāCheck if the current device includes a barometer sensor.
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.isAvailable();startMeasurementUpdates
Section titled āstartMeasurementUpdatesāBegin streaming barometer updates to the JavaScript layer.
Call with the measurement event to receive the updates.
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.startMeasurementUpdates();stopMeasurementUpdates
Section titled āstopMeasurementUpdatesāStop the continuous updates started via .
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.stopMeasurementUpdates();checkPermissions
Section titled ācheckPermissionsāReturn the current permission state for accessing barometer data.
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.checkPermissions();requestPermissions
Section titled ārequestPermissionsāRequest permission to access barometer data if required by the platform.
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.requestPermissions();Type Reference
Section titled āType ReferenceāGetMeasurementResult
Section titled āGetMeasurementResultāAlias for the most recent pressure sample.
export type GetMeasurementResult = Measurement;IsAvailableResult
Section titled āIsAvailableResultāResult returned by .
export interface IsAvailableResult { /** * Indicates whether the device exposes a barometer sensor. * * @since 1.0.0 */ isAvailable: boolean;}PermissionStatus
Section titled āPermissionStatusāPermission information returned by and .
export interface PermissionStatus { /** * The permission state for accessing barometer measurements on the current platform. * * @since 1.0.0 */ barometer: BarometerPermissionState;}MeasurementEvent
Section titled āMeasurementEventāEvent payload emitted when is active.
export type MeasurementEvent = Measurement;Measurement
Section titled āMeasurementāAir pressure and relative altitude values sampled from the device barometer.
export interface Measurement { /** * The static air pressure in hectopascals (hPa). * * @since 1.0.0 */ pressure: number;
/** * The change in altitude relative to the time updates started. * Only available on iOS; Android will always return `0`. * * @since 1.0.0 */ relativeAltitude: number;
/** * The timestamp of the measurement in milliseconds since the Unix epoch. * * @since 1.0.0 */ timestamp: number;}BarometerPermissionState
Section titled āBarometerPermissionStateāPermission state union including limited for platforms that can throttle sensor access.
export type BarometerPermissionState = PermissionState | 'limited';PermissionState
Section titled āPermissionStateāPlatform permission states supported by Capacitor.
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';Source Of Truth
Section titled āSource Of TruthāThis page is generated from the pluginās src/definitions.ts. Re-run the sync when the public API changes upstream.
Keep going from Getting Started
Section titled āKeep going from Getting StartedāIf you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-barometer for the native capability in Using @capgo/capacitor-barometer, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.