Windindi
Windindi

Reputation: 412

Health Kit reading permission

I have a app which writes active calories data to health kit. To prevent duplication of data writing in health kit i read health kit active calories to check if one instance already exsists.

I was under the impression that to read active calories from health kit we need to ask user permission to read active calories.

But after some testing i have observed that i am able to read the active calories data from health kit without getting the user permission.

Is this normal behaviour, that i am able to read data from health kit without the user permission beacuse i have written it?

Should i continue with this implementation or is this a bug?

Upvotes: 3

Views: 3399

Answers (2)

Windindi
Windindi

Reputation: 412

Found the answer in deep hidden documentation of health kit.

If your app is given share permission but not read permission, you see only the data that your app has written to the store. Data from other sources remains hidden.

If your app has permission to read a data type, you can query that data from the HealthKit store; however, even knowing that the user has denied your request to read data could reveal private health information. Therefore, your app cannot determine whether it has permission to read a particular type of data. If the user does not grant permission, queries for the restricted data types return only the samples that your app has shared. Otherwise, the HealthKit store appears to be empty.

So its not a bug.We can read data written by us in health kit.

Upvotes: 8

Jesper
Jesper

Reputation: 7605

Apple's documentation says:

Because health data can be sensitive, HealthKit grants users control over their data by providing fine-grained control over the information that apps can share. The user must explicitly grant each app permission to read and write data to the HealthKit store. Users can grant or deny permission separately for each type of data. For example, a user could let your app read the step count data but prevent it from reading the blood glucose level. To prevent possible information leaks, an app does not know whether it has been denied permission to read data. From the app’s point of view, if the app has been denied permission to read data, no data of that type exists.

If you are able to read actual items from the store and you are sure that you haven't already allowed a previous version of the application the right access (check Settings), this sounds like a bug that should be reported to Apple.

Upvotes: 2

Related Questions