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

Saving sleep data to Healthkit #109

Open
prabhjotAppmobi opened this issue Mar 11, 2019 · 0 comments
Open

Saving sleep data to Healthkit #109

prabhjotAppmobi opened this issue Mar 11, 2019 · 0 comments

Comments

@prabhjotAppmobi
Copy link

prabhjotAppmobi commented Mar 11, 2019

I have a requirement to add sleep data to healthkit from Ionic App. I have been using 'saveQuantitySample' available in documentation. I tried below code shared, the healthkit plugin shows us that 'Quantity type string was invalid'. I even tried to pass quantity parameter too but same results. Is saving HKCategoryTypeIdentifierSleepAnalysis supported by plugin?

If we pass 'HKCategoryTypeIdentifierSleepAnalysis' in querySampleType method available in documentation, It is returning us correct values but not allowing us to save the same Type.

 window['plugins'].healthkit.saveQuantitySample(
        {
          'startDate': new Date(new Date().getTime() - 24 * 60 * 60 * 1000), // a day ago
          'endDate': new Date(), // now
          'sampleType': 'HKCategoryTypeIdentifierSleepAnalysis',
          'unit': '',
          'amount' : 1, //Considering 0 for Asleep and 1 for In Bed.

        },
        function (value) {
          alert("Success running saveQuantitySample, result: " + value);
        },
        function (error) {
          alert("error running saveQuantitySample, result: " + error);
        },
    );
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

1 participant