iOS 10 Beta8 and HealthKit Authorization Issue

environment: iOS Beta8 on iPhoneSE with watchOS3 Beta6 on Apple Watch Sport 38mm

app build by XCode 8 Beta6

problem:

when iOS app calling requestAuthorizationToShareTypes, the app will fault but the code run fine on iOS9

Please tell me whether you have the same problem. Either 'Run fine for me on iOS10 beta8' or 'I have the same issue'. Thanks in advance.

I'm seing the same thing using iOS 10 beta 8 (14A5346a). I've tried many different parmeters. Always crashes. Works fine on iOS 9.


Env: iPhone 5s

Dev Env: 8 beta 6 (8S201h)


Chris

Thanks Chris. Now we know it may not be our problem. So I sent an email to Apple's South Asia, HK, Taiwan and South Korea Developer Relations Manager. Hope that he can help as iOS10 will be released soon.

Hi Chris,


I found out the issue. When Apple request us to provide a sample that demonstrate the issue. We found that iOS10 now require these 2 keys defined in info.plist:

NSHealthShareUsageDescription="heath s zh-hans"; // if you need read health data

NSHealthUpdateUsageDescription="heath u zh-hans"; // if you need write health data


Hope this help your case too.


P.S.

If you have different language for info.plist, you need to provide all.

This is correct. The error is :


Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSHealthShareUsageDescription must be set in the app's Info.plist in order to request read authorization.'


Adding the keys:

NSHealthShareUsageDescription="why this app needs to read your healthkit data"; // if you need read health data - this explanation is shown to the user during authorization

NSHealthUpdateUsageDescription="why this app needs to read your healthkit data"; // if you need write health data - this explanation is shown to the user during authorization


This works for a deployed app.


My problem is that it doesn't work in unit testing a framework. Has anyone managed to get this autorization working for unit tests?

iOS 10 Beta8 and HealthKit Authorization Issue
 
 
Q