react-native-health icon indicating copy to clipboard operation
react-native-health copied to clipboard

Check permission

Open jaroslav009 opened this issue 2 years ago • 6 comments

I'm getting 1 in AppleHealthKit.Constants.Permissions.HeartRate and it could be turned on or turned off it'll be always 1

testing in: IOS 16

here code: const permissions = { permissions: { read: [ AppleHealthKit.Constants.Permissions.BloodGlucose, AppleHealthKit.Constants.Permissions.HeartRate, ], write: [ AppleHealthKit.Constants.Permissions.BloodGlucose, AppleHealthKit.Constants.Permissions.HeartRate, ], }, } as HealthKitPermissions

appleHealthKit.getAuthStatus(permissions, (err, response) => { // when I turned off HeartRate but turned on BloodGlucose I'm getting such a response: // {"read": [2, 1], "write": [2]}} // If I turned on HeartRate response will be the same })

jaroslav009 avatar Feb 10 '23 13:02 jaroslav009

is there anybody out there?

jaroslav009 avatar Feb 14 '23 18:02 jaroslav009

Looking at the getAuthStatus docs I see that it should be returning 2 if it is in fact turned on.

I'm seeing a similar issue where I have HeartRate, RestingHeartRate, SleepAnalysis and ActivitySummary all turned on, I verified by looking in the Apple Health app, yet my response looks like this:

results:  Object {
  "permissions": Object {
    "read": Array [
      1,
      1,
      1,
      1,
    ],
    "write": Array [],
  },
}

pjsandwich avatar Mar 08 '23 01:03 pjsandwich

@jaroslav009 looks like this is just a bug in the lib: check this issue

tldr: "sharing authorized" (or expecting to see 2) for read permissions is confusing. "sharing authorized" means that the app has access to write the value for that type.

I also noticed that if you haven't requested write access, the write array won't return anything, which is annoying because the docs say it should return 0, 1, or 2... So, not sure if this function is actually helpful at all honestly

pjsandwich avatar Mar 08 '23 01:03 pjsandwich

@jaroslav009 looks like this is just a bug in the lib: check this issue

tldr: "sharing authorized" (or expecting to see 2) for read permissions is confusing. "sharing authorized" means that the app has access to write the value for that type.

I also noticed that if you haven't requested write access, the write array won't return anything, which is annoying because the docs say it should return 0, 1, or 2... So, not sure if this function is actually helpful at all honestly

maybe is there any other option to check Heart rate? Because I can't check if it writes

jaroslav009 avatar Mar 08 '23 17:03 jaroslav009

I'm also getting this error, returns 1 regardless of whether the permission was allowed or not

lewisd1996 avatar Apr 26 '23 14:04 lewisd1996

@jaroslav009 looks like this is just a bug in the lib: check this issue

tldr: "sharing authorized" (or expecting to see 2) for read permissions is confusing. "sharing authorized" means that the app has access to write the value for that type.

I also noticed that if you haven't requested write access, the write array won't return anything, which is annoying because the docs say it should return 0, 1, or 2... So, not sure if this function is actually helpful at all honestly

is the bug fixed?

ftaibi avatar Aug 06 '24 11:08 ftaibi