This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 58).
Expo Pedometer
A library that provides access to the device's pedometer sensor.
Pedometer from expo-sensors uses the system step counter sensor for live updates, and the Recording API on Android/Core Motion on iOS for step history.
Pedometer is not available in Expo Go for Android. Expo Go does not include the
ACTIVITY_RECOGNITIONpermission that Pedometer needs. With this permission, Google Play could classify Expo Go as a health app. To use Pedometer on Android, create a development build.
iOS keeps collecting step history automatically (up to seven days). On Android, step history requires the pedometerPlayServicesEnabled config plugin option, Google Play services Recording API support, and an active subscribeRecordingAsync() subscription. Unsubscribing makes previously collected history inaccessible, and Android retains up to 10 days since the latest subscription. The subscription helpers (subscribeRecordingAsync() / unsubscribeRecordingAsync()) are no-ops on iOS.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Configuration in app config
You can configure Pedometer from expo-sensors using its built-in config plugin. The plugin allows you to configure properties that cannot be set at runtime and require building a new app binary to take effect.
Example app.json with config plugin
Configurable properties
Usage
API
import { Pedometer } from 'expo-sensors';
Methods
Checks user's permissions for accessing pedometer.
Promise<PermissionResponse>Get the step count between two dates.
As Apple documentation states:
Only the past seven days worth of data is stored and available for you to retrieve. Specifying a start date that is more than seven days in the past returns only the available data.
As Android's documentation states:
Note:
LocalRecordingClientstores up to 10 days of data. Data is only accessible while there is an active subscription.
On Android, call subscribeRecordingAsync() before querying step history and keep it active if you want
the previous days to be available.
Promise<PedometerResult>a promise that fulfills with a PedometerResult.
Returns whether the pedometer is enabled on the device.
Promise<boolean>a promise that fulfills with a boolean, indicating whether the pedometer is
available on this device.
Check whether step history is supported on this device. On iOS, historical data is collected automatically (up to seven days).
Note: On Android, this checks whether the required Play Services Recording API components are available. Step history is only accessible while there is an active
subscribeRecordingAsync()subscription.
Promise<boolean>a promise that fulfills with a boolean, indicating whether
historical step count data is available on this device.
Asks the user to grant permissions for accessing pedometer.
Promise<PermissionResponse>Subscribe to pedometer tracking. Step count will be tracked by Google Play Services Recording API, if available, until unsubscribed. Subsequent calls are safe and ignored.
As Android's documentation states:
Note:
LocalRecordingClientstores up to 10 days of data. Data is only accessible while there is an active subscription.
Promise<void>a promise that fulfills when the subscription is successful.
Unsubscribe from pedometer tracking.
As Android's documentation states:
Note: To free up resources, you should make sure to unsubscribe from the collection of sensor data when your app is no longer in need of it. Unsubscribing will also reset the historical data that was collected.
Promise<void>a promise that fulfills when the unsubscription is successful.
Subscribe to pedometer updates.
Pedometer updates will not be delivered while the app is in the background. The
getStepCountAsyncmethod can be used to get the step count between two dates. On Android, historical step counts require Play Services Recording API support and an activesubscribeRecordingAsync()subscription.
EventSubscriptiona Subscription that enables you to call
remove() when you would like to unsubscribe the listener.
Interfaces
A subscription object that allows to conveniently remove an event listener from the emitter.
Types
Callback function providing event result as an argument.
void
Literal type: union
Permission expiration time. Currently, all permissions are granted permanently.
Acceptable values are: 'never' | number