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

HealthValue > Value type should be "number|string" for Sleep. #310

Open
swakeert opened this issue May 1, 2023 · 1 comment
Open

HealthValue > Value type should be "number|string" for Sleep. #310

swakeert opened this issue May 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@swakeert
Copy link

swakeert commented May 1, 2023

Describe the bug
Sleep data value is one of "INBED", "ASLEEP", "AWAKE", "DEEP", "REM" and "CORE", whereas the type of HealthValue > Value is fixed to a number.

To Reproduce
Steps to reproduce the behavior:
Run getSleepSamples with any options and you will note on success the data contains strings in value.

appleHealthKit.getSleepSamples(
  options,
  (err: Object, results: HealthValue[]) => {
    if (err) {
      console.log('err', err);
    }
    console.log('sleep results', results);
  },
);

>>>
 LOG  sleep results [{"endDate": "2023-05-01T08:54:35.278+0530", "id": "2073C587-B362-4634-840D-3974601CB657", "sourceId": "com.apple.health.41FEA228-7118-49E9-8136-4A807461C7FB", "sourceName": "Swakeert’s iPhone 14 Plus", "startDate": "2023-05-01T08:50:58.000+0530", "value": "INBED"}, {"endDate": "2023-05-01T08:50:42.000+0530", "id": "8E832D0B-C890-4074-A6D8-0F350CC9FD2D", "sourceId": "com.apple.health.41FEA228-7118-49E9-8136-4A807461C7FB", "sourceName": "Swakeert’s iPhone 14 Plus", "startDate": "2023-05-01T08:50:39.000+0530", "value": "INBED"}
...

You can see here, strings are returned for the value object, while HealthValue is defined as number.

Expected behavior
Either
A) The types should be updated to support number or string.
or
B) The getSleepSampleQuery should not convert the values returned by AppleHealthKit to strings and return the integer values. Additionally, RN-HealthKit can export an Enum that maps the integers to the respective Sleep Categories.

Screenshots
"value": "INBED"

type of value = number

Smartphone (please complete the following information):

  • Device: [iPhone 14 Plus, reproducible on all devices]
  • OS: [iOS 16.4.1]
  • Version [latest]
@swakeert swakeert added the bug Something isn't working label May 1, 2023
@nicolashandalian
Copy link

any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants