I have an application that previously only requested these HealthKit authorizations:
However, I later decided I wanted to be able to delete calorie data. I am now trying to add calorieQuantityType as a typeToShare, but it is not working.
For some reason the app requests HealthKit authorization on every app start, and the permission doesn't work. The toggle also does not show in the Health section of the watch settings. If I reinstall the app, it does work. This obviously isn't okay from an end-user's perspective. Is this possible to work around, or is this a bug?
Code Block if let heartRateQuantityType = HKQuantityType.quantityType(forIdentifier: .heartRate) { self.heartRateQuantityType = heartRateQuantityType } else { fatalError("* Unable to get the heartRate type *") } if let calorieQuantityType = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned) { self.calorieQuantityType = calorieQuantityType } else { fatalError("* Unable to get the activeEnergyBurned type *") } let typesToShare: Set = [ HKQuantityType.workoutType() ] let typesToRead: Set = [ heartRateQuantityType, calorieQuantityType ]
However, I later decided I wanted to be able to delete calorie data. I am now trying to add calorieQuantityType as a typeToShare, but it is not working.
Code Block let typesToShare: Set = [ HKQuantityType.workoutType(), calorieQuantityType ] let typesToRead: Set = [ heartRateQuantityType, calorieQuantityType ] healthStore.requestAuthorization(toShare: typesToShare, read: typesToRead) { (success, error) in if let error = error { print(error.localizedDescription) } }
For some reason the app requests HealthKit authorization on every app start, and the permission doesn't work. The toggle also does not show in the Health section of the watch settings. If I reinstall the app, it does work. This obviously isn't okay from an end-user's perspective. Is this possible to work around, or is this a bug?