Hey,
I’m using Pedometer Expo in my app which am developing.
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
});
}
);
this is the _subscribe( ) function which is as per the documentation.
I have changed the Date functions as below
const startdate = new Date('July 4, 2018');
const startdate1 = startdate.getDate();
const enddate = new Date('July 5, 2018');
const enddate1 = enddate.getDate();
I’m doing this to access the stepcount for a particular day ie . One day from jul 4 to jul 5(24 hours)
I’m able to access the pedometer, ie. as i use an android device, google fit is asking the permission to access the fitness data.
when i click allow, steps are being generated
but the below code shows an error
<Text>
Steps taken in the last 24 hours: {this.state.pastStepCount}
</Text>
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
});
}
);
this shows an error saying
Steps taken in the last 24 hours:Could not get stepCount : TypeError : undefined is not a function(evaluating 'start.getTime()' )
I haven’t used any getTime() methods but i still get that error.
can anyone help me with that.
thank you