[英]Requesting authorization in HealthKit: why the result is always successful?
我要求仅通过以下方式访问某些健康信息:
let healthStore = HKHealthStore()
let types: Set<HKObjectType> = [distanceWalkingRunning]
healthStore.requestAuthorization(toShare: nil, read: types) { (success, error) in
completion(success, error)
}
然后,在首次启动该应用程序时,会向我显示标准对话框,供您选择是否要让Health来访问信息。 如果我点击“不允许”,则会显示一个警报视图,其中显示:
Health Access-您可以稍后在Health应用程序中打开健康数据类别。
他们将关闭警报和“运行状况”访问对话框,并显示应用程序的登录屏幕。 我可以看到, healthStore.requestAuthorization
方法调用中提供的completion
关闭healthStore.requestAuthorization
都为success
参数获取了true
值,为error
参数获取了nil
。
然后,我怎么知道该用户不允许访问“健康”?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.