Reputation: 1365
I have background HKObserverQuery working great in my app, but I realized that if the user disables HealthKit permissions after setting up the queries, they continue to launch the app in the background even if they return no results because of the change in permissions. I don't want to continue launching my app if the user doesn't want me tracking their activity--is there a way to address this?
Upvotes: 1
Views: 170
Reputation: 1037
You can disable background delivery for specific type using disableBackgroundDeliveryForType:withCompletion:
or disable ALL backgrounds delivery using disableAllBackgroundDeliveryWithCompletion:
methods of the HKHealthStore
.
You can do it inside the completion handler of your observer query if you find out there are no results and you think it is due to the fact the user has change the permissions, even though when reading items from HealthKit I don't think you can tell if the user denied reading permission or there aren't any items (This is due to privacy concern, where knowing that the user denied the reading access for blood pressure samples might yield the user has some medical problem with her blood pressure).
Upvotes: 0