Comments (6)
Hi, it's actually in seconds, see this debugging screenshot of XCode 6.2, running on my iPhone 6 /w iOS 8.2:
Can you send me the JS code you used to save the workout?
from healthkit.
Admittedly I'm not 100% up to date with the latest version, but here is what I am using:
var startDate = new Date(); //This is created at the beginning of the workout
var minutesCompleted = 5;
var energyBurn = 40;
window.plugins.healthkit.saveWorkout({
'activityType': 'HKWorkoutActivityTypeFunctionalStrengthTraining',
'quantityType': null,
'startDate': $scope.startDate,
'endDate': null,
'duration': minutesCompleted * 60,
'energy': energyBurn,
'energyUnit': 'kcal',
'distance': null,
'distanceUnit': 'm'
},
function(msg){
console.log('HealthKit success: ' + msg);
},
function(msg){
console.log('HealthKit error: ' + msg);
}
);
Doesn't startDate.timeIntervalSince1970 in line 121 of what is in mater now return milliseconds though which we are then adding seconds to?
I do need to test on the updated Health.m file though, but I was just curious that it seemed like it was subtracting seconds from milliseconds. I am still on this old code:
int duration = 0;
NSNumber* startTime = [args objectForKey:@"startTime"];
NSTimeInterval _startInterval = [startTime doubleValue] / 1000; // strip millis
NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:_startInterval];
NSDate *endDate;
if ([args objectForKey:@"duration"]) {
duration = [[args objectForKey:@"duration"] intValue];
endDate = [NSDate dateWithTimeIntervalSince1970:_startInterval + duration];
} else if ([args objectForKey:@"endTime"]) {
NSNumber* endTime = [args objectForKey:@"endTime"];
NSTimeInterval _endInterval = [endTime doubleValue] / 1000; // strip millis
endDate = [NSDate dateWithTimeIntervalSince1970:_endInterval];
} else {
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no duration or endDate was set"];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
return;
}
from healthkit.
timeIntervalSince1970
is in seconds so it must be something else. Please update and let me know what you find out..
from healthkit.
Thanks for the verification Eddy, I put some breakpoints into Xcode and it is a mistake on my part for what I am passing in minutes. Never really mattered until 8.2 so I never really saw the time an output.
from healthkit.
👍
from healthkit.
@gylippus I tested your code with version 0.5.6 but its not working. I get:
*** Terminating app due to uncaught exception '_HKObjectValidationFailureException', reason: 'Invalid data type (null)'
@EddyVerbruggen Do you have an Idea? I tried exactly the same code like gylippus.
from healthkit.
Related Issues (20)
- 0.5.6 => ** BUILD FAILED ** HOT 4
- iOS app store rejection due to HKClinicalRecord HOT 7
- NSUnknownKeyException HOT 1
- Authorization to share the following types is disallowed HOT 4
- Privacy Policy Link HOT 3
- Error: Cannot find plugin.xml for plugin "needs". Please try adding it again. HOT 3
- Saving sleep data to Healthkit
- using this plugin for HKWorkoutActivityTypeMindAndBody data Type
- adding Mindful Minutes?
- Timestamp not getting with recorded data HOT 2
- HKClinicalRecord Flagged for Review HOT 11
- My app was rejected because of Clinical Health Records API HOT 1
- Clinical records Fork: queryClinicalSampleType & queryForClinicalRecordsWithFHIRResourceType hangs indefinitely HOT 1
- querySampleType not calling its callback
- Possible to get workout route data?
- The permission settings page does not open
- saveCategorySample?
- Permissions and Workout data? HOT 2
- Oxygen saturation
- How to query and return a subset of resutls like what findWorkouts() returns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from healthkit.