Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete/Discard previously saved data from HealthKit

I'm developing an app that gives the users the option to track what they ate. One of the features the app suggest is to select a food item as Eaten. When a user does that, I share that info with the HealthKit.

A user can then decide to uncheck that item and return its previous state: Uneaten. I wonder if I can query the previously saved food item and choose to delete it from the HealthKit as it isn't relevant for the user anymore?

UPDATE

Well, After reading almost the entire documentation of HealthKit I found out that HKHealthStore object has a method: deleteObject:withCompletion:. Yet I can't seem to successfully delete an HKCorrelation that stores the food item I previously saved to HealthKit, though the call finish successfully (I can still see the data in the Health App)...

like image 298
goldengil Avatar asked Sep 24 '14 08:09

goldengil


1 Answers

Use the deleteObject:withCompletion: API to delete the objects you saved. If you saved an HKCorrelation you must delete each of the objects you saved with the correlation as well.

like image 112
Allan Avatar answered Sep 18 '22 06:09

Allan