0

後叫stop()方法我在離子3.x版做了一步計數器的問題, 這是代碼步驟計數器插件提供了錯誤時,第一次

import { Stepcounter } from '@ionic-native/stepcounter'; 

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 
}) 
} 

我得到以下錯誤

service not registered: [email protected] 

請幫我一把。 任何建議表示讚賞。 謝謝。

+0

您是否嘗試導入「https:// github.com/ihadeed/cordova-plugin-stepcounter.git」而不是「https:// github.com/texh/cordova-plugin-stepcounter.git」? – Johny

+0

感謝您的這一點,但我實際上放棄使用stepcounter插件的想法,因爲它不支持所有的android設備,所以我用谷歌適合api計數用戶的步驟 –

回答

-1

使用md-man和實際開始請求完成,您將按鈕轉換爲「停止」按鈕之間有一段時間。

註釋說明:

if (this.buttonIcon === 'md-walk') { 

    // Change buttons (instant) 

    this.stepcounter.start(startOffset).then((res: any) => { 

    // The counter has actually started (remember this is async) 

    }).catch((err) => this.failure(err)) 
} 

爲了解決這個問題,你應該啓用then內停止按鈕「開始完成」。

+0

感謝您的回覆 但問題不在於那裏。 您是否看到我在代碼下編寫的錯誤? –

+0

你在哪一行得到錯誤? – Fenton