From f75f0428ef6b285ab55fc744b7761c2cbe9fde4b Mon Sep 17 00:00:00 2001 From: Robert Herber Date: Wed, 12 Jun 2024 08:01:10 +0200 Subject: [PATCH] feat: add appleEffortScore serialization --- ios/Constants.swift | 2 +- ios/Serializers.swift | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ios/Constants.swift b/ios/Constants.swift index 1e7e91b1..babfb863 100644 --- a/ios/Constants.swift +++ b/ios/Constants.swift @@ -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") \ No newline at end of file +let METUnit = HKUnit(from: "kcal/hr·kg") diff --git a/ios/Serializers.swift b/ios/Serializers.swift index bcd8a9f8..5ca51e85 100644 --- a/ios/Serializers.swift +++ b/ios/Serializers.swift @@ -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) }