dariosalvi78 / cordova-plugin-health

Cordova plugin for the HealthKit and Google Fit frameworks
MIT License
175 stars 126 forks source link

Electrocardiogram (ECG samples) #235

Open medericdegoy opened 2 years ago

medericdegoy commented 2 years ago

Hi, I tried to add this but this is way over my head. Thanks Dario for your work! I'd love to access ECG samples (HKElectrocardiogramType) in this plugin. I found a React native plugin that did it : https://github.com/agencyenterprise/react-native-health/blob/master/docs/getElectrocardiogramSamples.md but I don't know obj-c. Would you consider including this type in a next version ? thanks :)

dariosalvi78 commented 2 years ago

mm, would be cool to add yes, but my objective-c is really bad too! The iOS code of this plugin is the same as the one in https://github.com/EddyVerbruggen/HealthKit . You may try using the underlying plugin (which is still exposed through this one) to query for the HKElectrocardiogramType and see if you get any data. Something like:

window.plugins.healthkit.querySampleType(
        {
          'startDate': new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000), // three days ago
          'endDate': new Date(),
          'sampleType': 'HKElectrocardiogramType',
          'unit': '???' // not sure what goes here: voltage?
        },
        callback,
        callback
    );

I cannot test it myself as I don't have anything to generate ECG with.

Please let me know if it works and, if it does, I'd be happy to add ECG to this plugin.

For future reference, the full documentation about how to access ECG is here.