Hello all
I have an issue in doing a step counter in ionic v3.x.
this is the code
import { Stepcounter } from '@ionic-native/stepcounter';
constructor(private stepcounter: Stepcounter){
stepcounter.deviceCanCountSteps().then((res: any) => {
if (res == false) {
let alert = this.alertCtrl.create({
title: 'Alert',
subTitle: 'Oops!! Your device is not able to count your steps !!',
buttons: ['OK']
});
alert.present();
}
}).catch((err) => this.failure(err))
}
startPedometer() {
if (this.buttonIcon === 'md-walk') {
this.buttonIcon = "md-man";
this.startbuttonDisabled = false
this.stopbuttonDisabled = true
let startOffset = 0
this.stepcounter.start(startOffset).then((res: any) => {
this.success("Started : " + res)
}).catch((err) => this.failure(err))
}
else if (this.buttonIcon === 'md-man') {
this.buttonIcon = "md-walk";
this.stopbuttonDisabled = false
this.startbuttonDisabled = true
this.stepcounter.stop().then((res: any) => {
this.count = res
}).catch((err) => this.failure(err))
}
}
ionViewDidEnter(){
this.stepcounter.getStepCount().then((res:any)=>{
console.log("---------counts-----------"+JSON.stringify(res));
this.count = res
})
}
the following error is displayed after I press the the stop button second time.