ios - 如何检测用户是否不允许 Apple Health Kit 授权?

标签 ios swift healthkit hkhealthstore

我在我的应用程序中使用 AppleHealthKit。一切正常。问题是我无法检测到用户在请求许可时是否点击了“不允许”按钮。

enter image description here

通过这种方法,我的应用程序使用了 HealthKit,即使用户不允许这样做也是如此。

requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in
        if( completion != nil ) {
            completion(success:success,error:error)
        }

苹果文档:

enter image description here

所以基本上我的问题是如何检测到这一点?

最佳答案

您无法检测到它,这是设计使然:

To help prevent possible leaks of sensitive health information, your app cannot determine whether a user has granted permission to read data. If you are not given permission, it simply appears as if there is no data of the requested type in the HealthKit store.

(来自 HKHealthStore)

关于ios - 如何检测用户是否不允许 Apple Health Kit 授权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38801941/

相关文章:

ios - Health Kit 读取权限状态

iphone - UIVIew Controller 中何时调用 ViewDidUnload 和 Dealloc 方法?

ios - Apple Maps 应用程序或 MapKit 用于转弯导航

ios - 透明折线

ios - 无法从 HealthKit 获取合理格式的 HRV 读数

ios - Swift ResearchKit HealthKit QuestionStep

ios - 如何在 Xcode 6 中将设备添加到开发门户?

ios - 如何快速制作不同形状的 ImageView

ios - 如何在单元格上创建一个 "LIKE"按钮并符合 MVC?

ios - 触摸时黑色叠加层消失在 UIImageView 背景上