HealthKit Authorization Status

Payal Kandlur
1 min readJan 8, 2021

--

A question that has always been around being “How do we know if the user has given access to the health records, if yes which are those data?”.

First things first, if you are only reading data, HealthKit does not provide any information about whether or not the user has granted permissions to access the required data. Apple has clearly mentioned this in their documentation:

“To help maintain the privacy of sensitive health data, HealthKit does not tell you when the user denies your app permission to query data. Instead, it simply appears as if HealthKit does not have any data matching your query.”

Refer: https://developer.apple.com/documentation/healthkit/hkauthorizationstatus

Whereas, for sharing the data (in other terms writing) it returns us the status of whether the user has given permissions or denied.

The method authorizationStatus(for:) returns the app’s authorization status for sharing the specified data type.

  1. notDetermined (status 0) — The user has not yet chosen to authorize access to the specified data type.
  2. sharingDenied (status 1) — The user has explicitly denied your app permission to save data of the specified type.
  3. sharingAuthorized (status 2) — The user has explicitly authorized your app to save data of the specified type.

For more refer:

  1. https://developer.apple.com/documentation/healthkit/hkauthorizationstatus
  2. https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus

--

--

No responses yet