- SDK Version: 44
- Android
- expo-sensors (Pedometer)
I am trying to count user steps in background using TaskManager and BackgroundFetch.
I use Pedometer.watchStepCount() functions
example code:
TaskManager.defineTask(PEDOMETER_TASK_NAME, async ({ data, error }) => {
if (error) {
return;
}
Pedometer.watchStepCount((data) => {
AsyncStorage.setItem(“steps”, JSON.stringify(data.steps));
});
});
async function registerBackgroundPedometerFetchAsync() {
return BackgroundFetch.registerTaskAsync(PEDOMETER_TASK_NAME, {
minimumInterval: 1,
stopOnTerminate: false, // android only,
startOnBoot: true, // android only
});
}
this solution doesn’t work, I was trying to use Pedometer.watchStepCount() in combination with
Location.startLocationUpdatesAsync() but there was no effect.
Is it possible to do it in expo ?