ios – Learn how to discover out, if permission to READ heartrate utilizing HealthKit on watchOS is given?

0
47


So I’ve an watchOS app the place customers can observe their out of doors actions and that features heartrate. All of that’s working positive, however in help we typically get customers that complain that the app just isn’t monitoring their heartrate. And in virtually all of the circumstances the lacking READ permission for heartrate is the issue. Now I would like so as to add somewhat trace contained in the app, that this permission is lacking in order that the customers will know and hopefully have the ability to repair the issue on their very own.
The one downside now… How?

I attempted the next manner:

let healthStore = HKHealthStore()
let heartRateType = HKObjectType.quantityType(forIdentifier: .heartRate)!
let authStatus = healthStore.authorizationStatus(for: heartRateType)
// authStatus will likely be .sharingAuthorized even WITHOUT learn permissions and solely write permissions given

however that solely provides me the SHARE-permission standing. I need the READ-permission standing.
So when in settings I permit writing of heartrate however decline studying of it, this authStatus remains to be approved.

Additionally simply attempting to begin my HKAnchoredObjectQuery will NOT give me an error within the consequence handler. It is going to be referred to as as soon as (like it could if I had given the permission) however solely with empty samples. However I’d have anticipated an error saying I’ve no permissions?!? However that is not the case.

So my last query: Is there a option to inform if I’ve the READ permission for heartrate on watchOS utilizing HealthKit?