Skip to content

Commit

Permalink
feat: add appleEffortScore serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
robertherber committed Jun 12, 2024
1 parent 2b7c82a commit f75f042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ios/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ let HKDataTypeIdentifierHeartbeatSeries = "HKDataTypeIdentifierHeartbeatSeries"

let SpeedUnit = HKUnit(from: "m/s") // HKUnit.meter().unitDivided(by: HKUnit.second())
// Support for MET data: HKAverageMETs 8.24046 kcal/hr·kg
let METUnit = HKUnit(from: "kcal/hr·kg")
let METUnit = HKUnit(from: "kcal/hr·kg")
6 changes: 6 additions & 0 deletions ios/Serializers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func serializeUnknownQuantity(quantity: HKQuantity) -> [String: Any]? {
}
}

if #available(iOS 18.0, *) {
if quantity.is(compatibleWith: HKUnit.appleEffortScore()) {
return serializeQuantity(unit: HKUnit.appleEffortScore(), quantity: quantity)
}
}

if quantity.is(compatibleWith: SpeedUnit) {
return serializeQuantity(unit: SpeedUnit, quantity: quantity)
}
Expand Down

0 comments on commit f75f042

Please sign in to comment.