Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exception 'NSInvalidArgumentException' NSHealthUpdateUsageDescritption

Tags:

ios

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

Info.plist has this entry

<key>NSHealthShareUsageDescription</key>
<string>some string value stating the reason</string>
like image 947
Jose Castro Avatar asked Jun 16 '16 15:06

Jose Castro


3 Answers

If you already added NSHealthShareUsageDescription but still get the exception.

It may be due to that the description is too short.

Make sure the description is longer than 12 characters for all locales.

e.g.

HelloHello -> Crash!!

HelloHelloHi -> OK

like image 140
roytornado Avatar answered Nov 08 '22 04:11

roytornado


The error wants NSHealthUpdateUsageDescription to be set. Those are different keys as you can see here: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

  • NSHealthShareUsageDescription: Specifies a localized string that describes why the app wants to read HealthKit data. See NSHealthShareUsageDescription for details.

  • NSHealthUpdateUsageDescription: Specifies a localized string that describes why the app wants to write data to the HealthKit store. See NSHealthUpdateUsageDescription for details.

like image 36
Lou Franco Avatar answered Nov 08 '22 03:11

Lou Franco


If your app need use HealthKit, you should add read and write privileges in the Info.plist.

Write Privilege:

<key>NSHealthUpdateUsageDescription</key>
<string>some string value stating the reason</string>

Read Privilege:

<key>NSHealthShareUsageDescription</key>
<string>some string value stating the reason</string>

enter image description here

like image 15
saneryee Avatar answered Nov 08 '22 03:11

saneryee