Skip to content

Commit

Permalink
Add food and water (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazem El-Sisy authored and Terrillo Walls committed Feb 22, 2018
1 parent 15e89ce commit 7df6845
Show file tree
Hide file tree
Showing 7 changed files with 517 additions and 9 deletions.
39 changes: 38 additions & 1 deletion Constants/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,44 @@ export const Permissions = {
BodyMassIndex: "BodyMassIndex",
BodyTemperature: "BodyTemperature",
DateOfBirth: "DateOfBirth",
DietaryEnergy: "DietaryEnergy",
Biotin: "Biotin",
Caffeine: "Caffeine",
Calcium: "Calcium",
Carbohydrates: "Carbohydrates",
Chloride: "Chloride",
Cholesterol: "Cholesterol",
Copper: "Copper",
EnergyConsumed: "EnergyConsumed",
FatMonounsaturated: "FatMonounsaturated",
FatPolyunsaturated: "FatPolyunsaturated",
FatSaturated: "FatSaturated",
FatTotal: "FatTotal",
Fiber: "Fiber",
Folate: "Folate",
Iodine: "Iodine",
Iron: "Iron",
Magnesium: "Magnesium",
Manganese: "Manganese",
Molybdenum: "Molybdenum",
Niacin: "Niacin",
PantothenicAcid: "PantothenicAcid",
Phosphorus: "Phosphorus",
Potassium: "Potassium",
Protein: "Protein",
Riboflavin: "Riboflavin",
Selenium: "Selenium",
Sodium: "Sodium",
Sugar: "Sugar",
Thiamin: "Thiamin",
VitaminA: "VitaminA",
VitaminB12: "VitaminB12",
VitaminB6: "VitaminB6",
VitaminC: "VitaminC",
VitaminD: "VitaminD",
VitaminE: "VitaminE",
VitaminK: "VitaminK",
Zinc: "Zinc",
Water: "Water",
DistanceCycling: "DistanceCycling",
DistanceWalkingRunning: "DistanceWalkingRunning",
FlightsClimbed: "FlightsClimbed",
Expand Down
16 changes: 16 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// RCTAppleHealthKit+Methods_Dietary.h
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// Copyright © 2016 Greg Wilson. All rights reserved.
//

#import "RCTAppleHealthKit.h"

@interface RCTAppleHealthKit (Methods_Dietary)

- (void)saveFood:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)saveWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;

@end
409 changes: 409 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.m

Large diffs are not rendered by default.

42 changes: 39 additions & 3 deletions RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//

#import "RCTAppleHealthKit+TypesAndPermissions.h"
Expand Down Expand Up @@ -73,7 +72,44 @@ - (NSDictionary *)writePermsDict {
@"ActiveEnergyBurned" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned],
@"FlightsClimbed" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed],
// Nutrition Identifiers
@"DietaryEnergy" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryEnergyConsumed],
@"Biotin" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryBiotin],
@"Caffeine" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryCaffeine],
@"Calcium" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryCalcium],
@"Carbohydrates" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryCarbohydrates],
@"Chloride" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryChloride],
@"Cholesterol" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryCholesterol],
@"Copper" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryCopper],
@"EnergyConsumed" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryEnergyConsumed],
@"FatMonounsaturated" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatMonounsaturated],
@"FatPolyunsaturated" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatPolyunsaturated],
@"FatSaturated" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatSaturated],
@"FatTotal" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatTotal],
@"Fiber" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFiber],
@"Folate" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFolate],
@"Iodine" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryIodine],
@"Iron" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryIron],
@"Magnesium" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryMagnesium],
@"Manganese" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryManganese],
@"Molybdenum" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryMolybdenum],
@"Niacin" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryNiacin],
@"PantothenicAcid" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryPantothenicAcid],
@"Phosphorus" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryPhosphorus],
@"Potassium" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryPotassium],
@"Protein" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryProtein],
@"Riboflavin" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryRiboflavin],
@"Selenium" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietarySelenium],
@"Sodium" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietarySodium],
@"Sugar" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietarySugar],
@"Thiamin" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryThiamin],
@"VitaminA" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminA],
@"VitaminB12" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminB12],
@"VitaminB6" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminB6],
@"VitaminC" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminC],
@"VitaminD" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminD],
@"VitaminE" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminE],
@"VitaminK" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryVitaminK],
@"Zinc" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryZinc],
@"Water" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryWater],
// Sleep
@"SleepAnalysis" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSleepAnalysis],
// Mindfulness
Expand Down
14 changes: 12 additions & 2 deletions RCTAppleHealthKit/RCTAppleHealthKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//

#import "RCTAppleHealthKit.h"
Expand All @@ -13,6 +12,7 @@
#import "RCTAppleHealthKit+Methods_Activity.h"
#import "RCTAppleHealthKit+Methods_Body.h"
#import "RCTAppleHealthKit+Methods_Fitness.h"
#import "RCTAppleHealthKit+Methods_Dietary.h"
#import "RCTAppleHealthKit+Methods_Characteristic.h"
#import "RCTAppleHealthKit+Methods_Vitals.h"
#import "RCTAppleHealthKit+Methods_Results.h"
Expand Down Expand Up @@ -132,6 +132,16 @@ @implementation RCTAppleHealthKit
[self fitness_getFlightsClimbedOnDay:input callback:callback];
}

RCT_EXPORT_METHOD(saveFood:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self saveFood:input callback:callback];
}

RCT_EXPORT_METHOD(saveWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self saveWater:input callback:callback];
}

RCT_EXPORT_METHOD(getHeartRateSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self vitals_getHeartRateSamples:input callback:callback];
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ If new read/write permissions are added to the options object then the app user
```javascript
let options = {
permissions: {
read: ["Height", "Weight", "StepCount", "DateOfBirth", "BodyMassIndex"],
write: ["Weight", "StepCount", "BodyMassIndex"]
read: ["Height", "Weight", "StepCount", "DateOfBirth", "BodyMassIndex", "ActiveEnergyBurned"],
write: ["Height", "Weight", "StepCount", "BodyMassIndex", "Biotin", "Caffeine", "Calcium", "Carbohydrates", "Chloride", "Cholesterol", "Copper", "EnergyConsumed", "FatMonounsaturated", "FatPolyunsaturated", "FatSaturated", "FatTotal", "Fiber", "Folate", "Iodine", "Iron", "Magnesium", "Manganese", "Molybdenum", "Niacin", "PantothenicAcid", "Phosphorus", "Potassium", "Protein", "Riboflavin", "Selenium", "Sodium", "Sugar", "Thiamin", "VitaminA", "VitaminB12", "VitaminB6", "VitaminC", "VitaminD", "VitaminE", "VitaminK", "Zinc", "Water"]
}
};
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-apple-healthkit",
"version": "0.6.1",
"version": "0.6.3",
"description": "A React Native package for interacting with Apple HealthKit",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 7df6845

Please sign in to comment.