Members
(constant) NAME
Registered native TurboModule name: StepCounter.
- Source:
(constant) onErrorOccurred
Subscribe to serializable native errors without owning a counting session.
(constant) onStepCounterUpdate
Subscribe without owning or starting native sensors. Remove the returned listener on cleanup.
(constant) onStepDetected
Subscribe to platform detection/status diagnostics without starting sensors.
(constant) onStepsSensorInfo
Subscribe to platform-specific sensor metadata without starting sensors.
(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.
Example
import { StepCounter } from 'react-native-step-counter-newarch';
Methods
createStepCountFilter()
Create a stateful filter for live step-count updates.
Native pedometer APIs can already include device/OS false positives, and the Android accelerometer fallback can also react to quick hand rotation. This helper rejects totals that exceed the session's measurement-time cadence budget and rebases later values so demonstrated impossible steps do not come back. It cannot detect false steps hidden by idle time earlier in the session. A newer startDate or backend change resets adjustments; stale events are ignored. Create a fresh filter when restarting with the same startDate and backend. Unavailable distance remains null. Distance correction cannot attribute increments across unavailable intervals; only observed adjacent increments are removed.
isStepCountingSupported() → {Promise.<{supported: boolean, granted: 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 a counting sensor is present, including the Android accelerometer
fallback. granted - Whether permission is allowed, independently of sensor
availability. Android requires activity recognition for both backends on API 29+ under
the package consent policy. API 24–28 requires no activity runtime permission, so
granted is true. Check capabilities again after requesting permission;
support does not guarantee registration.
- Type
- Promise.<{supported: boolean, granted: 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. |
Returns:
- String Parsed Count Data.
- Type
- ParsedStepCountData
startStepCounterUpdate(start, callBack, onError) → {EventSubscription}
Start to subscribe stepCounter updates. If native start throws synchronously, the new listener is removed and the error is rethrown. If stopping a previous session throws, its listener is removed and that error propagates before a replacement listener or native session is started.
iOS
Live updates exclude activity recorded before this call, even for a past start date.
iOS queries the available history from start to the call time as a
baseline, then subtracts it from steps, distance, and floors. Emitted
startDate is that cutoff and endDate is the measurement
time. Future origins clamp to the call time. Missing baseline/current optional metrics
remain null; an unknown baseline stays null for the session. If the query fails with a
non-permission error, the first valid live sample becomes the baseline and its end
date becomes the cutoff; that sample is not emitted. Permission errors stop counting
even when reported by the baseline query. Zero-step, stale, or decreasing windows are
ignored without lowering baselines. Native
queryStepCounterDataBetweenDates instead returns the requested historical
interval (limited to available Core Motion history) without live-session subtraction.
It is not exposed by this TypeScript wrapper.
CMPedometer.startUpdates replaces the deprecated
CMStepCounter API.
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Date |
Native origin; on iOS, used to query the baseline, not to replay past steps. |
callBack |
StepCountUpdateCallback |
This callback function makes it easy for app developers to receive sensor events. |
onError |
Optional session-scoped native failure callback; remove the subscription on fatal errors. |
- Source:
- See:
Throws:
-
If start is an invalid Date, before replacing the current subscription.
- Type
- RangeError
Returns:
-
Returns a Subscription that enables you to call. Calling
remove()on the current subscription stops native sensors and removes that listener. Repeated removal and removing a replaced handle are safe. Independent debug listeners remain subscribed but do not keep sensors running.
- Type
- EventSubscription
Example
const startDate = new Date();
subscriptionRef.current = startStepCounterUpdate(startDate, (response) => {
const data = parseStepData(response);
})
stopStepCounterUpdate()
Stop the step counter updates.
iOS
CMStepCounter.stopStepCountingUpdates is deprecated since iOS 8.0. so
used CMPedometer.stopUpdates instead.