[MOD-2314] Core Motion Pedometer Not Giving Correct Step Count
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-11-21T03:48:40.000+0000 |
Affected Version/s | Release 5.2.0 |
Fix Version/s | Ti.CoreMotion 2.0.1 |
Components | Core Motion |
Labels | n/a |
Reporter | Taylor Thompson |
Assignee | Vijay Singh |
Created | 2016-02-24T18:47:53.000+0000 |
Updated | 2018-08-06T17:49:20.000+0000 |
Description
I'm working on building a fitness app that's main functionality will be around capturing step counts using the iOS Core Motion Pedometer. Using the old code listed below, I get a value that seems correct; however when I went out to follow Appcelerators documentation I noticed that there was a new way of doing this using the pedometer. Following Appcelerators documentation, I implemented the identical code given in the Pedometer example and the step count value that is now being returned is inaccurate. For 10 steps it reports a value of 200-300 and continues to grow from there. I also noticed that the .createPedometer method isn't in the documentation as a listed method. In fact, when trying to use the .createPedometer method yesterday, I was getting an error message back that said the method didn't exist; however, I upgraded the SDK to the latest and was then able to use it. OLD code that seems to work correctly when outputting value to console:
var CoreMotion = require("ti.coremotion");
if (CoreMotion.isStepCountingAvailable()) {
// If it can, it starts the step counter and outputs the data to the console
CoreMotion.startStepCountingUpdates({stepCounts: 1}, function(e) {
//$.stepLabel.text = e.numberOfSteps;
// Ti.API.info(JSON.stringify(e.numberOfSteps));
//CoreMotion.startStepCountingUpdates({stepCounts: 1}, function(e){
Ti.API.info(JSON.stringify(e.numberOfSteps));
$.stepLabel.text = JSON.stringify(e.numberOfSteps);
});
}
New Pedometer code that gives inaccurate value:
var CoreMotion = require("ti.coremotion");
var pedometer = CoreMotion.createPedometer();
if(pedometer.isStepCountingAvailable()){
$.stepLabel.text = "IT IS NOW!";
pedometer.startPedometerUpdates({
start: new Date(new Date().getTime() - 60 * 60 * 1000)
}, function(e) {
$.stepLabel.text = e.numberOfSteps;
});
}
Appcelerator Documentation Link on how to use Pedometer example:
http://docs.appcelerator.com/platform/latest/#!/guide/Core_Motion_Module
Appcelerator Documentation Link on how to use the Core Motion Module that doesn't list updated methods:
http://docs.appcelerator.com/platform/latest/#!/api/Modules.CoreMotion
Attachments
File | Date | Size |
---|---|---|
app.zip | 2016-03-03T15:34:35.000+0000 | 9771915 |