Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-barometer
bunx cap sync
import { CapacitorBarometer } from '@capgo/capacitor-barometer';

Get the most recent barometer reading captured by the native layer.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.getMeasurement();

Check if the current device includes a barometer sensor.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.isAvailable();

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();

Stop the continuous updates started via .

import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.stopMeasurementUpdates();

Return the current permission state for accessing barometer data.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.checkPermissions();

Request permission to access barometer data if required by the platform.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.requestPermissions();

Alias for the most recent pressure sample.

export type GetMeasurementResult = Measurement;

Result returned by .

export interface IsAvailableResult {
/**
* Indicates whether the device exposes a barometer sensor.
*
* @since 1.0.0
*/
isAvailable: boolean;
}

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;
}

Event payload emitted when is active.

export type MeasurementEvent = 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;
}

Permission state union including limited for platforms that can throttle sensor access.

export type BarometerPermissionState = PermissionState | 'limited';

Platform permission states supported by Capacitor.

export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.