For setting up the HealthKit framework Apple recommends the following way:
HealthKit capabilities in Xcode.isHealthDataAvailable method.HealthKit is both enabled and available, instantiate a HKHealthStore object.HealthKit data.My question is related with the number 2 step.
HealthKit is available as 8.0 and later and this method of course has the same availability. In iPad, in which HealthKit isn't available if you use the HealthKit entitlement, iOS doesn't let you even install the app at all.
What are the cases that this method can returns false ?
As per the discussion in the documentation it is for iPad which as you mention does not have HealthKit. In the store HealthKit-Apps can still be available for iPad but will not work with that feature.
Note that you can install an app that has the HealthKit framework on an iPad. What you can not do is install an app that has HealthKit as a requirement. By default, when you enable HealthKit in XCode, it adds both the entitlement, framework, and the requirement. But you can adjust the requirement in your app's .plist.
Now why would anyone want to include the HealthKit framework in an iPad app, especially if it doesn't have access to a HealthKit data store? The main reason I have found is then you can use all of the energy, distance, and weight unit formatting that is part of the HealthKit framework.
So, the isHealthDataAvailable is certainly desired for universal apps that use HealthKit but where the HealthKit store is not always available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With