开始
复制一个包含安装步骤和完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-pedometer`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/pedometer/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
bun add @capgo/capacitor-pedometerbunx cap syncimport { CapacitorPedometer } from '@capgo/capacitor-pedometer';API 介绍
Section titled “API 介绍”getMeasurement
Section titled “getMeasurement”获取指定时间范围内的步数计数器测量值。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.getMeasurement();isAvailable
Section titled “isAvailable”检查此设备上可用的计步器功能。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.isAvailable();startMeasurementUpdates
开始测量更新开始实时接收计步器测量数据
开 安卓 和 iOS, measurement 事件只在调用后触发 startMeasurementUpdates().
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.startMeasurementUpdates();stopMeasurementUpdates
停止测量更新停止接收实时步数计数测量更新。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.stopMeasurementUpdates();checkPermissions
名为“checkPermissions”的部分检查访问步数计数数据的权限
开 Android,这会检查 ACTIVITY_RECOGNITION 权限。
开 iOS,这会检查运动使用权限
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.checkPermissions();requestPermissions
名为“requestPermissions”的部分请求访问步数数据的权限。
On 在Android ACTIVITY_RECOGNITION 中,这个请求 权限。
在iOS
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.requestPermissions();复制到剪贴板
类型参考GetMeasurementOptions
标题为“类型参考”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;}Measurement
测量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;}IsAvailableResult
Section titled “IsAvailableResult”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;}PermissionStatus
Section titled “PermissionStatus”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';}MeasurementEvent
Section titled “MeasurementEvent”export type MeasurementEvent = Measurement;真实数据来源
Section titled “真实数据来源”本页面由插件生成 src/definitions.ts. 当公共 API 上游更改时,请重新运行同步。
继续从 Getting Started
标题:继续从 Getting Started如果您正在使用 Getting Started 来规划仪表板和 API 操作,连接它到 使用 @capgo/capacitor-pedometer 对于在使用 @capgo/capacitor-pedometer 中的本地能力 API Overview 对于在 API Overview 中的实现细节 Introduction 对于在 Introduction 中的实现细节 API Keys 为API Keys的实现细节,和 设备 为设备的实现细节,