Expo

Documentation

Pedometer

Uses Core Motion on iOS and the system hardware.Sensor on Android to get the user's step count.

For managed apps, you'll need to run expo install expo-sensors. To use it in a bare React Native app, follow its installation instructions.

import { Pedometer } from 'expo-sensors';

Returns whether the pedometer is enabled on the device.

  • Returns a promise that resolves to a Boolean, indicating whether the pedometer is available on this device.

Get the step count between two dates.

  • start (Date) -- A date indicating the start of the range over which to measure steps.
  • end (Date) -- A date indicating the end of the range over which to measure steps.

  • Returns a promise that resolves to an Object with a steps key, which is a Number indicating the number of steps taken between the given dates.
Note: iOS returns only last 7 days worth of data
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.

Subscribe to pedometer updates.

  • callback (function) A callback that is invoked when new step count data is available. The callback is provided a single argument that is an object with a steps key.

  • An EventSubscription object that you can call remove() on when you would like to unsubscribe the listener.

You'll need to configure an Android OAuth client for your app on the Google Play console for it to work as a standalone application on the Android platform. See https://developers.google.com/fit/android/get-api-key