I downloaded from Apple (https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/build_a_workout_app_for_apple_watch) the Workout app and tried to add requestAuthorization for the following types and then to read it.
func requestAuthorization() {
// The quantity type to write to the health store.
let typesToShare: Set = [
HKQuantityType.workoutType(),
HKQuantityType.quantityType(forIdentifier: .heartRate)!,
HKQuantityType.quantityType(forIdentifier: .oxygenSaturation)!,
HKQuantityType.quantityType(forIdentifier: .vo2Max)!,
]
// The quantity types to read from the health store.
let typesToRead: Set = [
HKQuantityType.quantityType(forIdentifier: .heartRate)!,
HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!,
HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning)!,
HKQuantityType.quantityType(forIdentifier: .distanceCycling)!,
HKQuantityType.quantityType(forIdentifier: .oxygenSaturation)!,
HKQuantityType.quantityType(forIdentifier: .vo2Max)!,
HKObjectType.activitySummaryType()
]
// Request authorization for those quantity types.
healthStore.requestAuthorization(toShare: typesToShare, read: typesToRead) { (success, error) in
// Handle error.
}
}
But unfortunately everything except vo2Max and oxygenSaturation is working.
My goal is to get the oxygenSaturation in my own app. Is this even possible?