This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Pedometer
一个提供访问设备计步器传感器功能的库
Pedometer from expo-sensors 使用 Android 上的系统 hardware.Sensor 和 iOS 上的 Core Motion 来获取用户的步数,同时还支持订阅计步器更新
安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
API
import { Pedometer } from 'expo-sensors';
Methods
Checks user's permissions for accessing pedometer.
Promise<PermissionResponse>Get the step count between two dates.
Promise<PedometerResult>Returns a promise that fulfills with a PedometerResult.
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.
Returns whether the pedometer is enabled on the device.
Promise<boolean>Returns a promise that fulfills with a boolean, indicating whether the pedometer is
available on this device.
Asks the user to grant permissions for accessing pedometer.
Promise<PermissionResponse>Subscribe to pedometer updates.
EventSubscriptionReturns a Subscription that enables you to call
remove() when you would like to unsubscribe the listener.
Pedometer updates will not be delivered while the app is in the background. As an alternative, on Android, use another solution based on
Health Connect API. On iOS, thegetStepCountAsyncmethod can be used to get the step count between two dates.
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