Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if the user doesn't allow Apple Health Kit Authorisation?

I am using AppleHealthKit in my application. Everything is working correctly. The problem is that I am not able to detect if the user taps "Don't Allow" button when asking for permission.

enter image description here

With this method, my application uses HealthKit, even though the user doesn't allow this.

requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in
        if( completion != nil ) {
            completion(success:success,error:error)
        }

Apple Documentation:

enter image description here

So basically my question is how to detect this?

like image 504
Byte Avatar asked Aug 06 '16 07:08

Byte


1 Answers

You cannot detect it, by design:

To help prevent possible leaks of sensitive health information, your app cannot determine whether a user has granted permission to read data. If you are not given permission, it simply appears as if there is no data of the requested type in the HealthKit store.

(from HKHealthStore)

like image 163
Sulthan Avatar answered Sep 28 '22 16:09

Sulthan