We're getting an error on a certain few devices when trying to authorize with the HealthKit API. The call to [HKHealthStore requestAuthorizationToShareTypes:::] fails consistently with the following error and the system-generated "Allow access to Health App" modal never gets presented:
Error Domain=com.apple.healthkit Code=100 "Failed to open database" UserInfo= {NSLocalizedDescription=Failed to open database}
We have a device that is able to reproduce this consistently, even after force quitting apps and restarting the OS. The phone seems to be unable to connect to HealthKit from any and all 3rd-party apps so it seems like a bug in HealthKit, not on our side. This seems to happen only on certain devices, but there doesn't seem to be anything special about the devices (all iPhones 4s and higher running iOS 9, 9.0.1, 9.0.2, or 9.1)
My question is: Has anyone else seen this error and if so what did you do to fix or mitigate the problem?
I've got a response from Apple in my bug report ticket (for the case when device reboot fixes the problem):
This was an iOS bug and has been fixed in iOS 9.3 beta 2. Developers can download the beta build from https://developer.apple.com/ios/download/ or wait until the 9.3 update is released to everyone.