HealthKit 血氧 SPO2

HealthKit Blood Oxygen SPO2

借助 Apple Watch 系列 6,您现在可以测量 SP02,即血氧中的血红蛋白含量。 iPhone 上的健康应用程序会向您显示呼吸部分的所有测量值。这是 COVID 患者的重要组成部分。

无论如何我都无法找到以编程方式访问此信息的方法。

我已经检查了最新的 Apple 文档中的所有 HKObjectTypes。 iOS 开发人员目前可以获得此信息吗?

任何信息都会有很大用处,因为一些研究人员正在请求它。

好的,有人告诉我这与 Oxygen 相同 Saturation.Here 是我用来查询 HK 的氧饱和度的代码:

    // Get SPO2
func getOxygenSaturation()
{
    // Type is SPO2 SDNN
    let osType:HKQuantityType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.oxygenSaturation)!

    let predicate = HKQuery.predicateForSamples(withStart: Date.distantPast, end: Date(), options: .strictEndDate)
    let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false)
    let osUnit:HKUnit = HKUnit(from: "%")

    
    let osQuery = HKSampleQuery(sampleType: osType,
                                 predicate: predicate,
                                 limit: 10,
                                 sortDescriptors: [sortDescriptor]) { (query, results, error) in
        guard error == nil else { print("error"); return }
        
        // Get the array of results from the sample query
        let sampleArray:[HKSample]? = results!
        
        // Loop through the array of rsults
        for (_, sample) in sampleArray!.enumerated()
        {
            // Be sure something is there
            if let currData:HKQuantitySample = sample as? HKQuantitySample
            {
                let os: Double = (currData.quantity.doubleValue(for: osUnit) * 100.0)
                let d1: Date = currData.startDate
                let str1 = SwiftLib.returnDateAndTimeWithTZ(date: d1, info: self.info!)

                Dispatch.DispatchQueue.main.async {
                    
                    self.tvOxygenValue.text = String(format: "%.0f%@", os, "%");
                    self.tvOxygenDate.text = str1
                    //print("\(os)");
                }
            }
        }
        
        print("Done")
        self.loadAndDisplayActivityInformation()
    }

    healthStore!.execute(osQuery)
}