Démarrage
Copiez un prompt de configuration avec les étapes d'installation et le guide Markdown complet pour ce plugin.
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.
Installer
Section intitulée « Installer »bun add @capgo/capacitor-pedometerbunx cap syncImporter
Section intitulée « Importer »import { CapacitorPedometer } from '@capgo/capacitor-pedometer';Vue d'ensemble de API
Section intitulée « Vue d'ensemble de API »getMeasurement
getMeasurementObtenez des mesures de pédomètre pour une plage de temps spécifiée.
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.getMeasurement();isAvailable
Section intitulée « isAvailable »Vérifiez les fonctionnalités de pédomètre disponibles sur cet appareil.
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.isAvailable();startMeasurementUpdates
Section intitulée « startMeasurementUpdates »Commencez à recevoir des mises à jour de mesures de pédomètre en temps réel.
Sur Android et iOS, le measurement L'événement n'est déclenché qu'après appel startMeasurementUpdates().
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.startMeasurementUpdates();stopMeasurementUpdates
Section intitulée “stopMeasurementUpdates”Arrêter les mises à jour de mesures de pédomètre en temps réel.
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.stopMeasurementUpdates();checkPermissions
Section intitulée “checkPermissions”Vérifier la permission d'accès aux données du pédomètre.
Activé Android, cela vérifie la ACTIVITY_RECOGNITION permission.
Activé iOS, cela vérifie la permission d'utilisation de la motion.
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.checkPermissions();requestPermissions
Sous-section intitulée « requestPermissions »Demander la permission d'accéder aux données du pédomètre.
Actif Android, cela demande la ACTIVITY_RECOGNITION permission.
Actif iOS, cela demande la permission d'utilisation de la motion.
import { CapacitorPedometer } from '@capgo/capacitor-pedometer';
await CapacitorPedometer.requestPermissions();Référence de type
Référence de typeGetMeasurementOptions
Obtenir les options de mesureexport 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
Section intitulée « Mesure »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
Résultat de disponibilité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
État de la permissionexport 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
Événement de mesureexport type MeasurementEvent = Measurement;Source de vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.