[英]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.