react-native-background-step-counter
Version:
This library provides an interface for tracking the number of steps taken by the user in a React Native app.
51 lines • 2.16 kB
TypeScript
import type { TurboModule } from "react-native";
/**
* `StepCountData` is an object with four properties: `distance`, `steps`, `startDate`, and `endDate`.
* StepCountData object - The Object that contains the step count data.
* counterType - The type of counter used to count the steps.
* steps - The number of steps taken during the time period.
* startDate - The start date of the data.
* endDate - The end date of the data.
* distance - The distance in meters that the user has walked or run.
* floorsAscended - number of floors ascended (iOS only)
* floorsDescended - number of floors descended (iOS only)
*/
export type StepCountData = {
counterType: string;
steps: number;
startDate: number;
endDate: number;
distance: number;
floorsAscended?: number;
floorsDescended?: number;
};
export declare const NAME = "BackgroundStepCounter";
export declare const VERSION = "0.0.1";
export declare const eventName = "BackgroundStepCounter.stepCounterUpdate";
export interface Spec extends TurboModule {
/**
* @description Check if the step counter is supported on the device.
* @async
* @returns {Promise<Record<string, boolean>>} Returns the `Promise` object,
* including information such as whether the user's device has a step counter sensor by default (`supported`)
* and whether the user has allowed the app to measure the pedometer data. (`granted`)
* granted - The permission is granted or not.
* supported - The step counter is supported or not.
* @example
* isStepCountingSupported().then((response) => {
* const { granted, supported } = response;
* setStepCountingSupported(supported);
* setStepCountingGranted(granted);
* });
*/
isStepCountingSupported(): Promise<Record<string, boolean>>;
startStepCounterUpdate(): void;
startBackgroundService(): void;
stopBackgroundService(): void;
stopStepCounterUpdate(): void;
addListener(eventName: string): void;
removeListeners(count: number): void;
}
declare const _default: Spec;
export default _default;
//# sourceMappingURL=NativeBackgroundStepCounter.d.ts.map