Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sleep analysis sample metadata at the query sample type result set #193

Open
Pickachu opened this issue Dec 4, 2020 · 1 comment
Open

Comments

@Pickachu
Copy link

Pickachu commented Dec 4, 2020

Hello!

First of all, thanks for the great plugin. Hope we will get support for all health kit data eventually, .o/

I'd like if the metadata field of sleep analysis were intentionally left out. if not it will be really good to have this field, since some apps add advanced useful data.

Here it is ignored when building the response from cordova Healthkit:

opts.sampleType = 'HKCategoryTypeIdentifierSleepAnalysis';
window.plugins.healthkit.querySampleType(opts, function (data) {
for (var i = 0; i < data.length; i++) {
var res = {};
res.id = data[i].UUID
res.startDate = new Date(data[i].startDate);
res.endDate = new Date(data[i].endDate);
if (data[i].value == 0) res.value = 'sleep.inBed';
else if (data[i].value == 1) res.value = 'sleep';
else res.value = 'sleep.awake';
res.unit = 'activityType';
res.sourceName = data[i].sourceName;
res.sourceBundleId = data[i].sourceBundleId;
result.push(res);

A sample of useful data added by AutoSleep, see the metadata field on Source Chain panel.

image

@dariosalvi78
Copy link
Owner

I wouldn't mind adding this information to the data returned, it is full of "juice". I am not sure how make this uniform across the API though. But to start from somewhere, we could maybe add the metadata object whenever available in iOS.

Would you mind sending a PR where you add the metadata to the returned object? (and please also add a line in the README to explain what happens)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants