Skip to main content
@capgo/capacitor-barometer Device APIs Open source

Barometer Capacitor plugin

Access device barometer for atmospheric pressure and altitude readings

Install

bun add @capgo/capacitor-barometer bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-barometer
  • pnpm add @capgo/capacitor-barometer
  • yarn add @capgo/capacitor-barometer

Guide

How to use Barometer in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Barometer plugin preview QR code

Using @capgo/capacitor-barometer

Capacitor plugin contract for working with the device barometer sensor.

Install

bun add @capgo/capacitor-barometer
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

API at a glance

Method Description
getMeasurement Get the most recent barometer reading captured by the native layer.
isAvailable Check if the current device includes a barometer sensor.
startMeasurementUpdates Begin streaming barometer updates to the JavaScript layer.
stopMeasurementUpdates Stop the continuous updates started via .
checkPermissions Return the current permission state for accessing barometer data.
requestPermissions Request permission to access barometer data if required by the platform.

Examples

getMeasurement()

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

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

const result = await CapacitorBarometer.getMeasurement();
console.log(result);

isAvailable()

Check if the current device includes a barometer sensor.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

const result = await CapacitorBarometer.isAvailable();
console.log(result);

startMeasurementUpdates()

Begin streaming barometer updates to the JavaScript layer.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

await CapacitorBarometer.startMeasurementUpdates();

stopMeasurementUpdates()

Stop the continuous updates started via .

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

await CapacitorBarometer.stopMeasurementUpdates();

checkPermissions()

Return the current permission state for accessing barometer data.

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

const result = await CapacitorBarometer.checkPermissions();
console.log(result);

requestPermissions()

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

import { CapacitorBarometer } from '@capgo/capacitor-barometer';

const result = await CapacitorBarometer.requestPermissions();
console.log(result);

Listen to events

addListener returns a handle. Call handle.remove() when the screen unmounts, or CapacitorBarometer.removeAllListeners() to clear every listener.

Full reference

Keep going from Using @capgo/capacitor-barometer

If you are using Using @capgo/capacitor-barometer to plan dashboard and API operations, connect it with @capgo/capacitor-barometer for the implementation detail in @capgo/capacitor-barometer, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.

FAQ

Barometer plugin FAQ

How do I install the Barometer plugin in a Capacitor app?

Run "bun add @capgo/capacitor-barometer" (or "npm install @capgo/capacitor-barometer"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-barometer" in your app code.

Does @capgo/capacitor-barometer work with React, Vue and Angular?

Yes. Barometer is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-barometer support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-barometer free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-barometer/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Barometer without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Barometer changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo