I'm setting up a Pedometer app in React Native using Expo, testing the code on my real Samsung s10 device.
I am using the Expo Pedometer documentation
However, when I use the Pedometer.getStepCountAsync
method, I get returned an error "Getting step count for date range is not supported on Android yet."
I am trying to make a pedometer app that reads users steps, and then puts them into some visuals for the user but I can't get the steps data.
My code is below: it reaches the error => line and returns the error mentioned above. :(
I've enabled the Fitness API in my Google Developer Console and am 99% sure I have the right credentials; as I have used the Google Login successfully in the same app.
const end = new Date();
const start = new Date();
start.setDate(end.getDate() - 1);
Pedometer.getStepCountAsync(start, end).then(
result => {
this.setState({ pastStepCount: result.steps });
},
error => {
this.setState({
pastStepCount: "Could not get stepCount: " + error
});
}
);
I guess the expected result is that I get the user's steps from the past day in the result but instead I get the error that it is not supported on android.
Yes, by using Core Motion (iOS) or Google Fit (Android) to get the user's step count. Any Android phone running on a 4.4 (KitKat) operating system or later will connect with Google Fit.
Pedometer unable to query steps, documentation unclear/contradictory.
I did something nasty as a workaround but it worked I added expo 33 as a legacy npm dependency and use only the pedometer module from there because currently they didn't implemented the pedometer functionality on android on the new Expo unimodules
package.json
And use it like this
import {Pedometer} from 'expo-legacy'
Surprisingly compiled and only increased 200kb the apk size