はじめに
このプラグインのインストール手順と完全な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.
インストール
「Install」セクションAIアシストセットアップを使ってプラグインをインストールできます。以下のコマンドで、お使いのAIツールに Capgo スキルを追加してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-pedometer` plugin in my project.手動セットアップを希望する場合は、以下のコマンドでプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-pedometerbunx cap syncインポート
「Import」セクションimport { CapacitorPedometer } from '@capgo/capacitor-pedometer';クイックスタート
「Quick start」セクションimport { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.requestPermissions();await CapacitorPedometer.startMeasurementUpdates();
await CapacitorPedometer.addListener('measurement', (event) => { updateStepCount(event.numberOfSteps);});例: iOSの履歴クエリ
「例: iOSの履歴クエリ」というセクションconst sample = await CapacitorPedometer.getMeasurement({ startDate: start.toISOString(), endDate: end.toISOString(),});よくある落とし穴
「Common pitfalls」セクション- 権限: iOSでのモーション、
ACTIVITY_RECOGNITIONAndroidでのモーション。 - Web: 利用不可。WebビルドではステップUIを非表示にします。
- 更新を停止:呼び出す
stopMeasurementUpdates()バッテリーを節約するため。
API の概要
「API 概要」セクションgetMeasurement
「getMeasurement」セクション指定した時間範囲の歩数計の測定値を取得します。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
const result = await CapacitorPedometer.getMeasurement();console.log(result);isAvailable
「isAvailable」セクションこのデバイスで利用可能な歩数計機能を確認します。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
const result = await CapacitorPedometer.isAvailable();console.log(result);startMeasurementUpdates
セクション「startMeasurementUpdates」歩数計の測定値のリアルタイム更新を受信し始めます。
オン Android と iOSでは、 measurement イベントは呼び出し後にのみ発火します startMeasurementUpdates().
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.startMeasurementUpdates();stopMeasurementUpdates
「stopMeasurementUpdates」セクション歩数計のリアルタイム計測更新の受信を停止します。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.stopMeasurementUpdates();checkPermissions
「checkPermissions」セクション歩数計データへのアクセス権限を確認します。
オン Androidでは、以下の ACTIVITY_RECOGNITION 権限を確認します。
iOSでは、モーション使用権限を確認します。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
const result = await CapacitorPedometer.checkPermissions();console.log(result);requestPermissions
「requestPermissions」セクション歩数計データへのアクセス権限をリクエストします。
オン Androidでは、以下の ACTIVITY_RECOGNITION 権限。
有効化 iOS、モーション使用の権限をリクエストします。
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
const result = await CapacitorPedometer.requestPermissions();console.log(result);型リファレンス
「型リファレンス」セクションGetMeasurementOptions
「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
「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
「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
「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
「MeasurementEvent」セクションexport type MeasurementEvent = Measurement;信頼できる情報源
「信頼できる情報源」セクションこのページはプラグインの src/definitions.tsから生成されています。上流で公開 API が変更されたら、sync を再実行してください。
Getting Started から続ける
「Getting Started からの続き」セクション以下を使用している場合: はじめに ダッシュボードと API の操作を計画するには、以下と連携してください @capgo/capacitor-pedometer の使用方法 @capgo/capacitor-pedometer を使用してネイティブ機能を利用する場合、 API の概要 API Overview の実装の詳細については、 はじめに Introduction の実装の詳細については、 API キー API Keys の実装の詳細については、 デバイス Devices の実装の詳細については。