I'm adding Weather info to my workout app. The documentation for HKMetadataKeyWeatherHumidity states that the unit is percentage humidity.
https://developer.apple.com/documentation/healthkit/hkmetadatakeyweatherhumidity
HKUnit.percent() has valid values from 0.0-1.0 inclusive.
https://developer.apple.com/documentation/healthkit/hkunit/1615517-percent
For a given humidity of 61% (i.e. 0.61 from my server), I'm saving the following quantity:
The health app is interpreting this at 1% humidity (school kid rounding) 0.61 --> 1% and 0.41 --> 0%.
When I print the humidity quantity of a workout recorded by Fitness app on Apple Watch, I see the value as 6100 %. Meanwhile, quantity.doubleValue(for: .percent()) prints out 61.0.
Seems that the Health app is scaling by a factor of 100. Has anyone else integrated humidity into their HealthKit compatible app? How were you saving it to make sure it displayed correctly in the Health app. I'd hate to account for this, only to find out it is a bug and have apple change their logic in the app.
https://developer.apple.com/documentation/healthkit/hkmetadatakeyweatherhumidity
HKUnit.percent() has valid values from 0.0-1.0 inclusive.
https://developer.apple.com/documentation/healthkit/hkunit/1615517-percent
For a given humidity of 61% (i.e. 0.61 from my server), I'm saving the following quantity:
Code Block metadata[HKMetadataKeyWeatherHumidity] = HKQuantity(unit: .percent(), doubleValue: humidity) builder.addMetadata(metadata) { }
The health app is interpreting this at 1% humidity (school kid rounding) 0.61 --> 1% and 0.41 --> 0%.
When I print the humidity quantity of a workout recorded by Fitness app on Apple Watch, I see the value as 6100 %. Meanwhile, quantity.doubleValue(for: .percent()) prints out 61.0.
Seems that the Health app is scaling by a factor of 100. Has anyone else integrated humidity into their HealthKit compatible app? How were you saving it to make sure it displayed correctly in the Health app. I'd hate to account for this, only to find out it is a bug and have apple change their logic in the app.