{ "id": "155106", "key": "MOD-2314", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10034", "key": "MOD", "name": "Appcelerator Modules", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "18724", "name": "Ti.CoreMotion 2.0.1", "archived": false, "released": true } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-11-21T03:48:40.000+0000", "created": "2016-02-24T18:47:53.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "17157", "name": "Release 5.2.0", "archived": false, "released": true, "releaseDate": "2016-02-23" } ], "issuelinks": [], "assignee": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-06T17:49:20.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13806", "name": "Core Motion" } ], "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. \r\n\r\nOLD code that seems to work correctly when outputting value to console: \r\n{code:javascript}\r\nvar CoreMotion = require(\"ti.coremotion\"); \r\nif (CoreMotion.isStepCountingAvailable()) { \r\n\t// If it can, it starts the step counter and outputs the data to the console \r\n\tCoreMotion.startStepCountingUpdates({stepCounts: 1}, function(e) { \r\n\t//$.stepLabel.text = e.numberOfSteps; \r\n\t// Ti.API.info(JSON.stringify(e.numberOfSteps)); \r\n\t//CoreMotion.startStepCountingUpdates({stepCounts: 1}, function(e){ \r\nTi.API.info(JSON.stringify(e.numberOfSteps)); \r\n $.stepLabel.text = JSON.stringify(e.numberOfSteps); \r\n\t}); \r\n\t} \r\n{code}\r\n\r\nNew Pedometer code that gives inaccurate value: \r\n{code:javascript}\r\nvar CoreMotion = require(\"ti.coremotion\"); \r\n\r\nvar pedometer = CoreMotion.createPedometer(); \r\n\r\nif(pedometer.isStepCountingAvailable()){ \r\n\t$.stepLabel.text = \"IT IS NOW!\"; \r\n\tpedometer.startPedometerUpdates({ \r\n\tstart: new Date(new Date().getTime() - 60 * 60 * 1000) \r\n\t}, function(e) { \r\n\t$.stepLabel.text = e.numberOfSteps; \r\n\t}); \r\n} \r\n{code}\r\nAppcelerator Documentation Link on how to use Pedometer example: \r\nhttp://docs.appcelerator.com/platform/latest/#!/guide/Core_Motion_Module \r\n\r\nAppcelerator Documentation Link on how to use the Core Motion Module that doesn't list updated methods: \r\nhttp://docs.appcelerator.com/platform/latest/#!/api/Modules.CoreMotion", "attachment": [ { "id": "58410", "filename": "app.zip", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-03T15:34:35.000+0000", "size": 9771915, "mimeType": "application/zip" } ], "flagged": false, "summary": "Core Motion Pedometer Not Giving Correct Step Count", "creator": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "OSX 10.10.5, Titanium SDK 5.1.2, iOS 9.2.1, Ti.CoreMotion 2.0.0", "comment": { "comments": [ { "id": "378585", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, \r\n\r\nPlease provide a full reproducible Alloy code which demonstrate the issue. Also provide the full steps to follow. We will try to regenerate the issue in our environment. \r\n\r\nThanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-03-03T14:36:04.000+0000", "updated": "2016-03-03T14:36:04.000+0000" }, { "id": "378593", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Can you tell me how I can get you the attached project? It's 50mb and the size limit on attachments is 10MB? I cannot post this project to GIT.", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-03T15:33:47.000+0000", "updated": "2016-03-03T15:33:47.000+0000" }, { "id": "378594", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I was able to attach the projects app directory with the code in it?", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-03T15:34:50.000+0000", "updated": "2016-03-03T15:34:50.000+0000" }, { "id": "378847", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hi may i know the coremotion module version you are using?", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-03-06T14:25:35.000+0000", "updated": "2016-03-06T14:25:35.000+0000" }, { "id": "378853", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "The fact that http://docs.appcelerator.com/platform/latest/#!/api/Modules.CoreMotion does not show the latest docs is a DOC issue that should be filed for [~bimmel]. Probably something isn't deployed correctly.\r\n\r\nRegarding the module itself, I guess you're using the latest 2.0.0 version which is pre-packaged in the latest Ti-release, coming from https://github.com/appcelerator-modules/ti.coremotion. I will debug the issue over the next days, thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-06T15:59:09.000+0000", "updated": "2016-03-06T15:59:09.000+0000" }, { "id": "378855", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "UPDATE: The method definitely returns the correct number of steps, bubbled from the native API. The difference between the two methods is, that the first one ({{startStepCountingUpdates}}) triggers the callback after a certain number of steps is reached. The new API provided by Apple (bridged to {{startPedometerUpdates}}) is based on a start date. That's why you receive 200 steps, because that's the number of steps in the last hour (60*60*1000). So if you want to use the step counter API, there is no problem in doing that, but Apple still courages to migrate it to the new API, that's why we also deprecated it.\r\n\r\nConsidering that, I wouldn't and can't change anything, except of clarifying this behavior in the docs. Thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-06T16:10:10.000+0000", "updated": "2016-03-06T16:10:10.000+0000" }, { "id": "378864", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hi,\r\n\r\nI also, get the similar behaviour as like reporter, new Pedometer code that gives inaccurate value but old code that seems to work correctly.\r\n\r\n*Steps To Reproduce:*\r\n1. Create an Alloy app.\r\n2. Replace the reporter attached code.\r\n3. Import \"ti.coremotion\" module into the tiapp.xml file.\r\n4. Run the app to the iPhone device.\r\n\r\n*Testing Environment:*\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.11.3\r\n Architecture = 64bit\r\n # CPUs = 4\r\n Memory = 8589934592\r\nNode.js\r\n Node.js Version = 4.2.2\r\n npm Version = 2.14.7\r\nTitanium CLI\r\n CLI Version = 5.0.6\r\nTitanium SDK\r\n SDK Version = 5.2.0.GA, 5.1.2.GA\r\n\r\n Target Platform = iphone\r\n\r\nModule Version: 2.0.0\r\niOS device version : 9.2.1\r\n\r\nThanks.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-06T20:34:47.000+0000", "updated": "2016-03-06T20:45:39.000+0000" }, { "id": "378865", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~morahman] Did you read me comment above? It's no inaccurate value, it's just a different one. Further reading about the behavior [here (Example)|http://pinkstone.co.uk/how-to-access-the-step-counter-and-pedometer-data-in-ios-9/] and [here (Apple docs)|https://developer.apple.com/library/prerelease/ios/documentation/CoreMotion/Reference/CMPedometer_class/index.html#//apple_ref/occ/instm/CMPedometer/startPedometerUpdatesFromDate:withHandler:]. If we use {{new Date()}} instead (which is the current date), it should give similar/same values. [~TaylorThompson] please validate so we can close this one, thank you for bringing up!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-06T20:45:19.000+0000", "updated": "2016-03-06T20:45:19.000+0000" }, { "id": "378917", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This still isn't giving me the behavior I'd expect. I changed the start: line to three different things below:\r\n\r\nstart: new Date() \r\nstart: new Date(new Date()) \r\nstart: new Date(new Date().getTime())\r\n\r\nAll of which give me similar behavior and I even have logic in my code so when I press a button it's supposed to give me back the last minute count of steps as what was provided in the documentation:\r\n\r\n$.btn.addEventListener('click', function(e){    pedometer.queryPedometerData({        start: new Date(new Date().getTime() - 60*1000),         end: new Date()    }, function (e) {            $.stepHistory.text = \"You walked \" + e.numberOfSteps + \" steps in the last minute.\";    });});\r\n\r\nWhen I deploy to phone and shake 10 times I get an output of around 170-180 and another 10 steps results in 300-400. When clicking the button to give me the last minute worth of steps I get the same number. What I'd expect is if I walk 10 steps, I'd get a number close to 10? I'm just trying to figure out how to get there...\r\n\r\nSDK 5.2.0 GA\r\nTarget Platform = iphoneModule \r\nVersion: 2.0.0\r\niOS device version : 9.2.1", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-07T14:48:30.000+0000", "updated": "2016-03-07T14:48:30.000+0000" }, { "id": "379689", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hey Hans,\r\n\r\nJust wanted to check and see if you've been able to take another look at this yet? I tested the code above and still ended up with a value I didn't expect. I'm just trying to figure out what I need to do to get a value that I'd expect like what I get using the old code. In other words, if I walk 10 steps I'm needing to get a value close to 10.\r\n\r\nTT", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-14T20:58:44.000+0000", "updated": "2016-03-14T20:58:44.000+0000" }, { "id": "380178", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey Taylor. Just thought the fact that it could be a thread-related issue. If you set {{true}} inside the {{}} section of your tiapp.xml, does that change something? EDIT: Or try [this version|https://www.dropbox.com/s/dpxhwa5hjsczm2c/ti.coremotion-iphone-2.0.1.zip?dl=0]. Thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-20T11:51:56.000+0000", "updated": "2016-03-20T11:55:20.000+0000" }, { "id": "380256", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've tried both to run on main thread as well as use the new CoreMotion module you sent. Instead of returning (e.numberOfSteps) I've changed it to return e. Looking at the screenshot I've linked below, you can see where it shows a time difference of about 10 seconds in the start and end date. However, the numberOfSteps value is 226 which can't possible be correct.\r\n\r\nhttps://oneok.sharefile.com/d-s9c9d60f9953477b9", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-21T15:49:48.000+0000", "updated": "2016-03-21T15:50:05.000+0000" }, { "id": "380678", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "What's the status on this?", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-25T12:28:33.000+0000", "updated": "2016-03-25T12:28:33.000+0000" }, { "id": "380679", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I'm working on a native example to compare it 1:1, but as we have other issues to also work on, it will take some more time here.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-25T12:33:00.000+0000", "updated": "2016-03-25T12:33:00.000+0000" }, { "id": "383189", "author": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hans,\r\n\r\nAny update on this yet? Do you know if there is any way to get health data out of the default iOS Health app as a workaround?", "updateAuthor": { "name": "TaylorThompson", "key": "taylorthompson", "displayName": "Taylor Thompson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-19T19:50:55.000+0000", "updated": "2016-04-19T19:50:55.000+0000" }, { "id": "383190", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey Taylor! Unfortunately not, yet. Too many different things to work on. If you want to help me, grab one of the demo apps from the web accessing the Pedometer API and log your results here. I didn't forget the issue, but please give me some more time to sort things out.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-19T19:58:15.000+0000", "updated": "2016-04-19T19:58:15.000+0000" }, { "id": "400454", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~TaylorThompson] You can still get the data from HealthKit (use Ti.HealthKit), but I still don't get how the data can be differently like natively, since no custom logic is applied. I will hand this one over to [~vijaysingh] have a second pair of eyes on it.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-11-05T20:44:20.000+0000", "updated": "2016-11-05T20:44:20.000+0000" }, { "id": "401502", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This issue is in Core motion module. So moving it to Module .", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-11-18T06:24:13.000+0000", "updated": "2016-11-18T06:24:13.000+0000" }, { "id": "401503", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "CMPedometerData properties \"numberOfSteps\" , \"distance\" etc., in Coremotion framework of apple , are NSNumber object type . In our code we were converting these properties to NSNumber assuming they are Int . \r\n\r\nPR: https://github.com/appcelerator-modules/ti.coremotion/pull/16", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-11-18T08:07:48.000+0000", "updated": "2016-11-18T08:07:48.000+0000" }, { "id": "401562", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~TaylorThompson], can you test [ti.coremotion-iphone-2.0.1.zip|https://www.dropbox.com/s/dpxhwa5hjsczm2c/ti.coremotion-iphone-2.0.1.zip?dl=0] with yout setup? I know it has been a while, but the changes in the casting could actually do the difference. Thank you!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-11-18T23:19:28.000+0000", "updated": "2016-11-18T23:19:28.000+0000" }, { "id": "401593", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Test-Case:\r\n{code:javascript}\r\nvar CoreMotion = require(\"ti.coremotion\"); \r\n \r\nvar pedometer = CoreMotion.createPedometer(); \r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: \"#fff\"\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n title: \"Start counting\"\r\n});\r\n\r\nvar stepLabel = Ti.UI.createLabel({\r\n top: 75\r\n});\r\n\r\nbtn.addEventListener(\"click\", function() {\r\n if (pedometer.isStepCountingAvailable()) { \r\n stepLabel.text = \"IT IS NOW!\"; \r\n pedometer.startPedometerUpdates({ \r\n start: new Date(new Date().getTime() - 60 * 60 * 1000) \r\n }, function(e) { \r\n stepLabel.text = e.numberOfSteps; \r\n }); \r\n } \r\n});\r\n\r\nwin.add(stepLabel);\r\nwin.add(btn);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-11-21T03:49:50.000+0000", "updated": "2016-11-21T03:49:50.000+0000" }, { "id": "401594", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "New release: https://github.com/appcelerator-modules/ti.coremotion/releases/tag/v2.0.1", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-11-21T03:51:47.000+0000", "updated": "2016-11-21T03:51:47.000+0000" }, { "id": "440120", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:49:20.000+0000", "updated": "2018-08-06T17:49:20.000+0000" } ], "maxResults": 25, "total": 25, "startAt": 0 } } }