Global

Members

(constant) NAME

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)

Source:

(constant) StepCounter

A module that allows you to get the step count data. CMStepCounter is deprecated in iOS 8.0. Used CMPedometer instead. floorsAscended - The number of floors ascended during the time period. iOS Only. floorsDescended - The number of floors descended during the time period. iOS Only. counterType - The type of counter used to count the steps.

Source:
Example
import { StepCounter } from '@dongminyu/react-native-step-counter';

Methods

isStepCountingSupported() → {Promise.<Record.<string, boolean>>}

Returns whether the stepCounter is enabled on the device. iOS 8.0+ only. Android is available since KitKat (4.4 / API 19).

Source:
See:
Returns:

A promise that resolves with an object containing the stepCounter availability. supported - Whether the stepCounter is supported on device. granted - Whether user granted the permission.

Type
Promise.<Record.<string, boolean>>

parseStepData(data) → {ParsedStepCountData}

Transform the step count data into a more readable format. You can use it or directly use the StepCountData type.

Parameters:
Name Type Description
data StepCountData

Step Counter Sensor Event Data.

Source:
Returns:
  • String Parsed Count Data.
Type
ParsedStepCountData

startStepCounterUpdate(start, callBack) → {EventSubscription}

Start to subscribe stepCounter updates. Only the past seven days worth of data is stored and available for you to retrieve. Specifying a start date that is more than seven days in the past returns only the available data.

iOS

CMStepCounter.startStepCountingUpdates is deprecated since iOS 8.0. so used CMPedometer.startUpdates instead.

Parameters:
Name Type Description
start Date

A date indicating the start of the range over which to measure steps.

callBack StepCountUpdateCallback

This callback function makes it easy for app developers to receive sensor events.

Source:
See:
Returns:
  • Returns a Subscription that enables you to call. When you would like to unsubscribe the listener, just use a method of subscriptions's remove().
Type
EventSubscription
Example
const startDate = new Date();
subscriptionRef.current = startStepCounterUpdate(startDate, (response) => {
   const data = parseStepCountData(response);
})

stopStepCounterUpdate()

Stop the step counter updates.

iOS

CMStepCounter.stopStepCountingUpdates is deprecated since iOS 8.0. so used CMPedometer.stopUpdates instead.

Source:
See: