有了苹果手表系列6,你现在可以测量你的SP02,你的血氧中的血红蛋白含量。iPhone上的健康应用程序会在呼吸部分向你显示所有的测量数据。这对于COVID患者来说是一个关键的组成部分。
无论如何,我都无法找到以编程方式访问此信息的方法。
我已经检查了最新的苹果文档中的所有HKObjectTypes。此信息目前对iOS开发人员可用吗?
正如几位研究人员所要求的那样,任何信息都将非常有用。
发布于 2020-12-05 00:45:10
好吧,我被告知这和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)
}https://stackoverflow.com/questions/65131045
复制相似问题