如果在app中调用了苹果健康,iOS10中会出现闪退。
控制台报出的原因是:
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文件中声明苹果健康的使用权限,所以在info.plist中添加以下key就可以了。
<key>NSHealthUpdateUsageDescription</key>
<string>some string value stating the reason</string>
<key>NSHealthShareUsageDescription</key>
<string>some string value stating the reason</string>
另外iOS 10 其他权限相对应的key 如下:
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
你必须 登录后 才能对文章进行评论!