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

Pedometer Capacitor plugin

Track steps, distance, pace, cadence, and floors with device pedometer sensors

Install

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

Guide

How to use Pedometer in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Pedometer plugin preview QR code

Using @capgo/capacitor-pedometer

Capacitor plugin for accessing pedometer data including steps, distance, pace, cadence, and floors.

Install

bun add @capgo/capacitor-pedometer
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 { CapacitorPedometer } from '@capgo/capacitor-pedometer';

API at a glance

Method Description
getMeasurement Get pedometer measurements for a specified time range.
isAvailable Check which pedometer features are available on this device.
startMeasurementUpdates Start receiving real-time pedometer measurement updates.
stopMeasurementUpdates Stop receiving real-time pedometer measurement updates.
checkPermissions Check permission to access pedometer data.
requestPermissions Request permission to access pedometer data.

Examples

getMeasurement()

Get pedometer measurements for a specified time range.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

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

isAvailable()

Check which pedometer features are available on this device.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

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

startMeasurementUpdates()

Start receiving real-time pedometer measurement updates.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

await CapacitorPedometer.startMeasurementUpdates();

stopMeasurementUpdates()

Stop receiving real-time pedometer measurement updates.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

await CapacitorPedometer.stopMeasurementUpdates();

checkPermissions()

Check permission to access pedometer data.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

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

requestPermissions()

Request permission to access pedometer data.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

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

Listen to events

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

Full reference

Keep going from Using @capgo/capacitor-pedometer

If you are using Using @capgo/capacitor-pedometer to plan native plugin work, connect it with @capgo/capacitor-pedometer for the implementation detail in @capgo/capacitor-pedometer, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

Pedometer plugin FAQ

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

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

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

Yes. Pedometer 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-pedometer 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-pedometer free and open source?

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

Can I update code that uses Pedometer 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 Pedometer 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