如何在观看独立应用程序上显示HealthKit权限

时间:2019-06-24 16:07:34

标签: swift health-kit watch-os

尝试构建需要健康数据的独立手表应用程序。但是,healthStore.requestAuthorization不在监视屏幕上显示任何内容。

@IBAction func showHeartrate() {

    if HKHealthStore.isHealthDataAvailable(){
        let healthStore = HKHealthStore()

        let types = Set([HKObjectType.quantityType(forIdentifier: .heartRate)!
            ])

        healthStore.requestAuthorization(toShare: types, read: types) { (success, error) -> Void in
            if !success{
                print("error occured")
            }
            if success{
                print("authrorized")
            }
        }
    }

}

0 个答案:

没有答案