Skip to content

fix(definitions): 'total-calories' is missing in the list of the data…#5

Open
UzverNumber47 wants to merge 1 commit into
mley:mainfrom
UzverNumber47:patch-1
Open

fix(definitions): 'total-calories' is missing in the list of the data…#5
UzverNumber47 wants to merge 1 commit into
mley:mainfrom
UzverNumber47:patch-1

Conversation

@UzverNumber47

Copy link
Copy Markdown

…Types

@mley

mley commented Nov 4, 2025

Copy link
Copy Markdown
Owner

Thanks for the PR. I think 'total-calories' are already implemented in Android, but not on iOS yet. I think we need something like this to make it work on iOS as well. But I haven't tested it yet.

diff --git a/ios/Sources/HealthPluginPlugin/HealthPlugin.swift b/ios/Sources/HealthPluginPlugin/HealthPlugin.swift
index fe4e376..925a7cd 100644
--- a/ios/Sources/HealthPluginPlugin/HealthPlugin.swift
+++ b/ios/Sources/HealthPluginPlugin/HealthPlugin.swift
@@ -100,6 +100,8 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
             return HKObjectType.quantityType(forIdentifier: .stepCount)
         case "active-calories":
             return HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)
+        case "total-calories":
+          return HKObjectType.quantityType(forIdentifier: .totalEnergyBurned)
         default:
             return nil
         }
@@ -166,6 +168,8 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
                             value = sum.doubleValue(for: HKUnit.count())
                         } else if(dataTypeString == "active-calories" && dataType.is(compatibleWith: HKUnit.kilocalorie())) {
                             value = sum.doubleValue(for: HKUnit.kilocalorie())
+                        } else if(dataTypeString == "total-calories" && dataType.is(compatibleWith: HKUnit.kilocalorie())) {
+                            value = sum.doubleValue(for: HKUnit.kilocalorie())
                         } else if(dataTypeString == "mindfulness" && dataType.is(compatibleWith: HKUnit.second())) {
                             value = sum.doubleValue(for: HKUnit.second())
                         }
@@ -566,3 +570,4 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
     ]

 }
+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants