Let me start by saying, it wouldn't surprise me if all of the following is user error. 🙃
I'm trying to write a Widget using WidgetKit, where the widget extension itself is querying the HealthKit database. The host app definitely has HealthKit authorization, but I'm not clear how to do the same for the extension.
I did add the requisite Info.plist entry in the widget extension, which cleared my first error. However, when I do my normal prompt for auth — the same one I use in my main app — I see this in the console:
This leads me to think this isn't my fault, but, perhaps I've missed the plot.
Any pointers/experience from anyone that's done this before?
Thank you!
I'm trying to write a Widget using WidgetKit, where the widget extension itself is querying the HealthKit database. The host app definitely has HealthKit authorization, but I'm not clear how to do the same for the extension.
I did add the requisite Info.plist entry in the widget extension, which cleared my first error. However, when I do my normal prompt for auth — the same one I use in my main app — I see this in the console:
Code Block 2020-07-10 14:13:39.035757-0400 BodyWidgetExtension[988:337871] [auth] FAILED prompting authorization request to share ( ), read ( HKQuantityTypeIdentifierStepCount )
This leads me to think this isn't my fault, but, perhaps I've missed the plot.
Any pointers/experience from anyone that's done this before?
Thank you!
Hi!
Widgets can get access to health data if the host app has permission (which I believe is the case here). However, it doesn't have the ability to request authorization (show the health permission screen).
The best practice here is to never call requestAuthorization in your widget code, and only determine the authorization status of your request through getRequestStatusForAuthorization API, then either display the health data or ask the user to grant permission in app depending on the result.
If I've misunderstood anything please let me know.
Widgets can get access to health data if the host app has permission (which I believe is the case here). However, it doesn't have the ability to request authorization (show the health permission screen).
The best practice here is to never call requestAuthorization in your widget code, and only determine the authorization status of your request through getRequestStatusForAuthorization API, then either display the health data or ask the user to grant permission in app depending on the result.
If I've misunderstood anything please let me know.