-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apple Health metrics: toothbrushing as sessions per day and as minutes per day #556
base: master
Are you sure you want to change the base?
Conversation
Once code has run with this and then another build of the app is used where the app does not yet support the metric, there are errors and warnings about the missing metric as well as crashes in places like Also, the app should report to the user that a goal configured for a metric is not being sourced as there is some issue. |
d3de888
to
4eea411
Compare
@@ -12,6 +12,7 @@ public enum HealthKitCategory : String, CaseIterable { | |||
case Heart = "Heart" | |||
case Mindfulness = "Mindfulness" | |||
case Nutrition = "Nutrition" | |||
case SelfCare = "Self Care" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These categories map to the categorizations in the Health app. Toothbrushing is under "Other".
@@ -51,6 +51,10 @@ public enum HealthKitConfig { | |||
QuantityHealthKitMetric(humanText: "Vitamin K", databaseString: "dietaryVitaminK", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryVitaminK), | |||
QuantityHealthKitMetric(humanText: "Water", databaseString: "water", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryWater), | |||
|
|||
// Self care | |||
ToothbrushingDailyMinutesHealthKitMetric.make(), | |||
ToothbrushingDailySessionsHealthKitMetric.make(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to have multiple top level metrics for the same underlying metric. There are lots of metrics where this could make sense, and the list risks getting far too long.
The way I think this should work:
- There is one metric for toothbrushing.
- On the preview/confirm page, there are additional settings to refine exactly how the metric is logged. These are stored using additional attributes on the autodata key on the goal. The preview updates as these settings are changed.
- For toothbrushing in particular, this should be either "Aggregate Total Daily Minutes", or reporting each toothbrushing session as a separate data point with its number of minutes. People can count sessions via adjusting aggday.
Note this will require some tweaks to the sync code to allow multiple data points per day to be synced correctly. A while back the app started including requestid with these points to help facilitate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customizing aggday
is possible with a custom goal. A typical do more (hustler) goal type will have its how to aggregate the day set to sum.
category: HealthKitCategory.SelfCare) | ||
} | ||
|
||
override func recentDataPoints(days: Int, deadline: Int, healthStore: HKHealthStore) async throws -> [any BeeDataPoint] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than this, can probably just implement valueInAppropriateUnits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was implemented for the purpose of specifying the healthkitMetric in the comment and yes, converting seconds to minutes.
Summary
Users have requested beeminding toothbrushing and using Apple Health and the Beeminder iOS app to do so.
As is, this is an initial implementation adding toothbrushing to the app's apple health integration.
Supports
Validation
Added data to Apple Health in the Simulator
Ran the app in the simulator. Set up a goal, linked it with Toothbrushing, let it log datapoints.