メインコンテンツにスキップ

はじめから始める

GitHub

CapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。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.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

Terminal window
bun add @capgo/capacitor-pedometer
bunx cap sync
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';

__CAPGO_KEEP_0__

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.getMeasurement();

isAvailable

isAvailable

このデバイスで利用可能な歩数計機能を確認してください。

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.isAvailable();

startMeasurementUpdates

startMeasurementUpdates

リアルタイム歩数計測値の更新を受け取り始めます。

オン Android および iOSイベントは、 measurement Copy to clipboard startMeasurementUpdates().

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.startMeasurementUpdates();

リアルタイム歩数計測値の更新を受信を停止します。

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.stopMeasurementUpdates();

歩数計測値へのアクセス許可を確認します。

オン Androidこのチェックは ACTIVITY_RECOGNITION 許可を確認します。 オン iOSこのチェックは運動使用許可を確認します。

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.checkPermissions();

歩数データへのアクセスを許可するよう求めます。

オン Androidこの場合、 ACTIVITY_RECOGNITION 許可を求めます。 オン iOSこの場合、運動使用許可を求めます。

import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.requestPermissions();
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;
}
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;
}
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;
}
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';
}
export type MeasurementEvent = Measurement;

このページはプラグインから生成されています src/definitions.ts. upstream の API が変更されたときに、再度 sync を実行してください。

Getting Started から続けてください。

Getting Started から続けてください。

「Getting Started から続けてください。」というセクション Getting Started を使用して、ダッシュボードと __CAPGO_KEEP_0__ の操作を計画する場合、__CAPGO_KEEP_0__ を接続してください。 @API/__CAPGO_KEEP_1__-pedometer を使用して、native capability を実装する @capgo/capacitor-pedometer の native capability の実装詳細 for the native capability in Using @capgo/capacitor-pedometer, API の実装詳細 for the implementation detail in API Overview, 概要の実装詳細 概要 API キー API キーと デバイス デバイスの実装詳細について