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
Section titled “Import”import { 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.