How to Check if HealthKit has been authorized

Note: authorizationStatus is to determine the access status only to write but not to read. There is no option to know whether your app has read access. FYI, https://stackoverflow.com/a/29128231/1996294

Here an example of requesting and checking permission access in HealthKitStore

// Present user with items we need permission for in HealthKit
healthKitStore.requestAuthorization(toShare: typesToShare, read: typesToRead, completion: { (userWasShownPermissionView, error) in

    // Determine if the user saw the permission view
    if (userWasShownPermissionView) {
        print("User was shown permission view")

        // ** IMPORTANT
        // Check for access to your HealthKit Type(s). This is an example of using BodyMass.
        if (self.healthKitStore.authorizationStatus(for: HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass)!) == .sharingAuthorized) {
            print("Permission Granted to Access BodyMass")
        } else {
            print("Permission Denied to Access BodyMass")
        }

    } else {
        print("User was not shown permission view")

        // An error occurred
        if let e = error {
            print(e)
        }
    }
})

Currently, there is no way the app can determine whether or not a user has granted permission to read health data.

Below is the description from Apple from authorizationStatus(for:):

To help prevent possible leaks of sensitive health information, your app cannot determine whether or not 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. 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.


You are misinterpreting what the success flag means in this context. When success is true, all that means is that iOS successfully asked the user about health kit access. It does NOT mean that they responded to that question with a 'yes'.

To determine if they said yes/no, you need to get more specific, and ask health kit if you have permission to read/write the particular type of data you're interested in. From the apple docs on HealthKit:

After requesting authorization, your app is ready to access the HealthKit store. If your app has permission to share a data type, it can create and save samples of that type. You should verify that your app has permission to share data by calling authorizationStatusForType: before attempting to save any samples.