Skip to content

Getting Started

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

Get pedometer measurements for a specified time range.

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

Check which pedometer features are available on this device.

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

Start receiving real-time pedometer measurement updates.

On Android and iOS, the measurement event is only fired after calling startMeasurementUpdates().

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.startMeasurementUpdates();

Stop receiving real-time pedometer measurement updates.

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

Check permission to access pedometer data.

On Android, this checks the ACTIVITY_RECOGNITION permission. On iOS, this checks the motion usage permission.

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

Request permission to access pedometer data.

On Android, this requests the ACTIVITY_RECOGNITION permission. On iOS, this requests motion usage permission.

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.requestPermissions();
export interface GetMeasurementOptions {
/**
* The start time for the measurement query (milliseconds since epoch).
*
* Required on **iOS**.
*
* @since 0.0.1
*/
start?: number;
/**
* The end time for the measurement query (milliseconds since epoch).
*
* Required on **iOS**.
*
* @since 0.0.1
*/
end?: number;
}
export interface Measurement {
/**
* The number of steps taken by the user.
*
* @since 0.0.1
*/
numberOfSteps?: number;
/**
* The estimated distance (in meters) traveled by the user.
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
distance?: number;
/**
* The approximate number of floors ascended.
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
floorsAscended?: number;
/**
* The approximate number of floors descended.
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
floorsDescended?: number;
/**
* The current pace (in seconds per meter).
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
currentPace?: number;
/**
* The current cadence (steps per second).
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
currentCadence?: number;
/**
* The average active pace (in seconds per meter).
*
* Only available on **iOS**.
*
* @since 0.0.1
*/
averageActivePace?: number;
/**
* The start time of this measurement (milliseconds since epoch).
*
* @since 0.0.1
*/
startDate?: number;
/**
* The end time of this measurement (milliseconds since epoch).
*
* @since 0.0.1
*/
endDate?: number;
}
export interface IsAvailableResult {
/**
* Whether step counting is available.
*
* @since 0.0.1
*/
stepCounting: boolean;
/**
* Whether distance measurement is available.
*
* Only `true` on **iOS** devices that support distance tracking.
*
* @since 0.0.1
*/
distance: boolean;
/**
* Whether pace measurement is available.
*
* Only `true` on **iOS** devices that support pace tracking.
*
* @since 0.0.1
*/
pace: boolean;
/**
* Whether cadence measurement is available.
*
* Only `true` on **iOS** devices that support cadence tracking.
*
* @since 0.0.1
*/
cadence: boolean;
/**
* Whether floor counting is available.
*
* Only `true` on **iOS** devices that support floor tracking.
*
* @since 0.0.1
*/
floorCounting: boolean;
}
export interface PermissionStatus {
/**
* Permission state for activity recognition.
*
* On **Android**, this is the `ACTIVITY_RECOGNITION` permission.
* On **iOS**, this is the motion usage permission.
*
* @since 0.0.1
*/
activityRecognition: 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
}
export type MeasurementEvent = Measurement;

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

If you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-pedometer for the native capability in Using @capgo/capacitor-pedometer, 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.