From d6736f47535de7157a55263c59491a7dca0eaf5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Mon, 22 Jul 2019 11:45:26 +0200 Subject: [PATCH 1/9] Added missing registration of dietary files. --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index ab99383a..8328d2f9 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; }; 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; }; 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; }; + B79BEDD622E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m in Sources */ = {isa = PBXBuildFile; fileRef = B79BEDD422E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -61,6 +62,8 @@ 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = ""; }; 64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = ""; }; 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = ""; }; + B79BEDD422E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Dietary.m"; sourceTree = ""; }; + B79BEDD522E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Dietary.h"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -93,6 +96,8 @@ 3774C88F1D2092F20000B3F3 /* RCTAppleHealthKit */ = { isa = PBXGroup; children = ( + B79BEDD522E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.h */, + B79BEDD422E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m */, 58C81E6E1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.h */, 58C81E6D1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.m */, 61232F911E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.h */, @@ -160,6 +165,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 3774C8841D2092F20000B3F3; @@ -182,6 +188,7 @@ 37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */, 3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */, 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */, + B79BEDD622E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m in Sources */, 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */, 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */, 3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */, From f366e31c9e0cffa62751c547e28bfb2426c4d4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Mon, 22 Jul 2019 11:47:23 +0200 Subject: [PATCH 2/9] Removed side effect. --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index 8328d2f9..35398cfe 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -165,7 +165,6 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - English, en, ); mainGroup = 3774C8841D2092F20000B3F3; From d999314467846caded208d405ce231a22e69aa7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 10:14:24 +0200 Subject: [PATCH 3/9] Added reproductive health permissions. --- Constants/Permissions.js | 136 +++++++++--------- .../RCTAppleHealthKit+TypesAndPermissions.m | 6 + 2 files changed, 76 insertions(+), 66 deletions(-) diff --git a/Constants/Permissions.js b/Constants/Permissions.js index d54f0b85..59be9b5b 100644 --- a/Constants/Permissions.js +++ b/Constants/Permissions.js @@ -4,69 +4,73 @@ * @type {Object} */ export const Permissions = { - ActiveEnergyBurned: "ActiveEnergyBurned", - AppleExerciseTime: "AppleExerciseTime", - BasalEnergyBurned: "BasalEnergyBurned", - BiologicalSex: "BiologicalSex", - BloodGlucose: "BloodGlucose", - BloodPressureDiastolic: "BloodPressureDiastolic", - BloodPressureSystolic: "BloodPressureSystolic", - BodyFatPercentage: "BodyFatPercentage", - BodyMass: "BodyMass", - BodyMassIndex: "BodyMassIndex", - BodyTemperature: "BodyTemperature", - DateOfBirth: "DateOfBirth", - 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", - DistanceSwimming: "DistanceSwimming", - DistanceWalkingRunning: "DistanceWalkingRunning", - FlightsClimbed: "FlightsClimbed", - HeartRate: "HeartRate", - Height: "Height", - LeanBodyMass: "LeanBodyMass", - MindfulSession: "MindfulSession", - NikeFuel: "NikeFuel", - RespiratoryRate: "RespiratoryRate", - SleepAnalysis: "SleepAnalysis", - StepCount: "StepCount", - Steps: "Steps", - Weight: "Weight", - Workout: "Workout" -} + ActiveEnergyBurned: 'ActiveEnergyBurned', + AppleExerciseTime: 'AppleExerciseTime', + BasalBodyTemperature: 'BasalBodyTemperature', + BasalEnergyBurned: 'BasalEnergyBurned', + BiologicalSex: 'BiologicalSex', + Biotin: 'Biotin', + BloodGlucose: 'BloodGlucose', + BloodPressureDiastolic: 'BloodPressureDiastolic', + BloodPressureSystolic: 'BloodPressureSystolic', + BodyFatPercentage: 'BodyFatPercentage', + BodyMass: 'BodyMass', + BodyMassIndex: 'BodyMassIndex', + BodyTemperature: 'BodyTemperature', + Caffeine: 'Caffeine', + Calcium: 'Calcium', + Carbohydrates: 'Carbohydrates', + Chloride: 'Chloride', + Cholesterol: 'Cholesterol', + Copper: 'Copper', + DateOfBirth: 'DateOfBirth', + DistanceCycling: 'DistanceCycling', + DistanceSwimming: 'DistanceSwimming', + DistanceWalkingRunning: 'DistanceWalkingRunning', + EnergyConsumed: 'EnergyConsumed', + FatMonounsaturated: 'FatMonounsaturated', + FatPolyunsaturated: 'FatPolyunsaturated', + FatSaturated: 'FatSaturated', + FatTotal: 'FatTotal', + Fiber: 'Fiber', + FlightsClimbed: 'FlightsClimbed', + Folate: 'Folate', + HeartRate: 'HeartRate', + Height: 'Height', + Iodine: 'Iodine', + Iron: 'Iron', + LeanBodyMass: 'LeanBodyMass', + Magnesium: 'Magnesium', + Manganese: 'Manganese', + MenstruationFlow: 'MenstruationFlow', + MindfulSession: 'MindfulSession', + Molybdenum: 'Molybdenum', + Niacin: 'Niacin', + NikeFuel: 'NikeFuel', + OvulationTestResult: 'OvulationTestResult', + PantothenicAcid: 'PantothenicAcid', + Phosphorus: 'Phosphorus', + Potassium: 'Potassium', + Protein: 'Protein', + RespiratoryRate: 'RespiratoryRate', + Riboflavin: 'Riboflavin', + Selenium: 'Selenium', + SexualActivity: 'SexualActivity', + SleepAnalysis: 'SleepAnalysis', + Sodium: 'Sodium', + StepCount: 'StepCount', + Steps: 'Steps', + Sugar: 'Sugar', + Thiamin: 'Thiamin', + VitaminA: 'VitaminA', + VitaminB12: 'VitaminB12', + VitaminB6: 'VitaminB6', + VitaminC: 'VitaminC', + VitaminD: 'VitaminD', + VitaminE: 'VitaminE', + VitaminK: 'VitaminK', + Water: 'Water', + Weight: 'Weight', + Workout: 'Workout', + Zinc: 'Zinc' +}; diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m index a54f03fb..299b7fcb 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m @@ -53,6 +53,12 @@ - (NSDictionary *)readPermsDict { @"MindfulSession" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierMindfulSession], //workouts @"Workout" : [HKObjectType workoutType], + // Reproductive Health + @"BasalBodyTemperature" : [HKObjectType categoryTypeForIdentifier:HKQuantityTypeIdentifierBasalBodyTemperature], + @"MenstruationFlow" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierMenstrualFlow], + @"OvulationTestResult" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierOvulationTestResult], + @"SexualActivity" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSexualActivity], + }; return readPerms; } From 25381b3aa3e458b708bb44b098074847a8e6829c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 13:24:33 +0200 Subject: [PATCH 4/9] Fixed wrong permission identifier. --- RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m index 299b7fcb..50c8b339 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m @@ -54,7 +54,7 @@ - (NSDictionary *)readPermsDict { //workouts @"Workout" : [HKObjectType workoutType], // Reproductive Health - @"BasalBodyTemperature" : [HKObjectType categoryTypeForIdentifier:HKQuantityTypeIdentifierBasalBodyTemperature], + @"BasalBodyTemperature" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSexualActivity], @"MenstruationFlow" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierMenstrualFlow], @"OvulationTestResult" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierOvulationTestResult], @"SexualActivity" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSexualActivity], From a71c171bc71ac90556746aedab3f218b2140873b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 16:16:08 +0200 Subject: [PATCH 5/9] Finished implementation. Docs pending. --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 7 + ...ppleHealthKit+Methods_ReproductiveHealth.h | 10 ++ ...ppleHealthKit+Methods_ReproductiveHealth.m | 130 ++++++++++++++ RCTAppleHealthKit/RCTAppleHealthKit+Queries.h | 54 ++++-- RCTAppleHealthKit/RCTAppleHealthKit+Queries.m | 165 ++++++++++++++++++ .../RCTAppleHealthKit+TypesAndPermissions.m | 2 +- RCTAppleHealthKit/RCTAppleHealthKit.m | 29 ++- 7 files changed, 378 insertions(+), 19 deletions(-) create mode 100644 RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.h create mode 100644 RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.m diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index ab99383a..de05c424 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; }; 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; }; 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; }; + B790AE8A22E5CCDE00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m in Sources */ = {isa = PBXBuildFile; fileRef = B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -61,6 +62,8 @@ 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = ""; }; 64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = ""; }; 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = ""; }; + B790AE8822E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.h"; sourceTree = ""; }; + B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -93,6 +96,8 @@ 3774C88F1D2092F20000B3F3 /* RCTAppleHealthKit */ = { isa = PBXGroup; children = ( + B790AE8822E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.h */, + B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */, 58C81E6E1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.h */, 58C81E6D1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.m */, 61232F911E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.h */, @@ -160,6 +165,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 3774C8841D2092F20000B3F3; @@ -180,6 +186,7 @@ 3774C89B1D2095450000B3F3 /* RCTAppleHealthKit+Queries.m in Sources */, 3774C8A11D20A6B90000B3F3 /* RCTAppleHealthKit+Utils.m in Sources */, 37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */, + B790AE8A22E5CCDE00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m in Sources */, 3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */, 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */, 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */, diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.h b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.h new file mode 100644 index 00000000..30294fe5 --- /dev/null +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.h @@ -0,0 +1,10 @@ +#import "RCTAppleHealthKit.h" + +@interface RCTAppleHealthKit (Methods_Vitals) + +- (void)reproductiveHealth_getBasalBodyTemperatureSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; +- (void)reproductiveHealth_getMenstruationFlowSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; +- (void)reproductiveHealth_getOvulationTestResultSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; +- (void)reproductiveHealth_getSexualActivitySamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; + +@end diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.m b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.m new file mode 100644 index 00000000..c43c4332 --- /dev/null +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.m @@ -0,0 +1,130 @@ +#import "RCTAppleHealthKit+Methods_ReproductiveHealth.h" +#import "RCTAppleHealthKit+Queries.h" +#import "RCTAppleHealthKit+Utils.h" + +@implementation RCTAppleHealthKit (Methods_Sleep) + +- (void)reproductiveHealth_getBasalBodyTemperatureSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback +{ + BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false]; + HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit degreeCelsiusUnit]]; + NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; + NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; + + if (startDate == nil) { + callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); + return; + } + + HKQuantityType *sampleType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBasalBodyTemperature]; + NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionStrictStartDate]; + + [self fetchQuantitySamplesOfType:sampleType + unit:unit + predicate:predicate + ascending:ascending + limit:HKObjectQueryNoLimit + completion:^(NSArray *results, NSError *error) { + if(results){ + callback(@[[NSNull null], results]); + return; + } else { + NSLog(@"error getting basal body temperature samples: %@", error); + callback(@[RCTMakeError(@"error getting basal body temperature samples", nil, nil)]); + return; + } + }]; + +} + +- (void)reproductiveHealth_getMenstruationFlowSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback +{ + BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false]; + NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; + NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; + NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit]; + + if (startDate == nil) { + callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); + return; + } + + NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionStrictStartDate]; + + [self fetchMenstruationFlowSamples:predicate + ascending:ascending + limit:limit + completion:^(NSArray *results, NSError *error) { + if (results) { + callback(@[[NSNull null], results]); + return; + } else { + NSLog(@"Error getting menstruation flow samples: %@", error); + callback(@[RCTMakeError(@"Error getting menstruation flow samples", error, nil)]); + return; + } + }]; + +} + +- (void)reproductiveHealth_getOvulationTestResultSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback +{ + BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false]; + NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; + NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; + NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit]; + + if (startDate == nil) { + callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); + return; + } + + NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionStrictStartDate]; + + [self fetchOvulationTestResultSamples:predicate + ascending:ascending + limit:limit + completion:^(NSArray *results, NSError *error) { + if (results) { + callback(@[[NSNull null], results]); + return; + } else { + NSLog(@"Error getting ovulation test result samples: %@", error); + callback(@[RCTMakeError(@"Error getting ovulation test result samples", error, nil)]); + return; + } + }]; + +} + +- (void)reproductiveHealth_getSexualActivitySamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback +{ + BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false]; + NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; + NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; + NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit]; + + if (startDate == nil) { + callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); + return; + } + + NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionStrictStartDate]; + + [self fetchSexualActivitySamples:predicate + ascending:ascending + limit:limit + completion:^(NSArray *results, NSError *error) { + if (results) { + callback(@[[NSNull null], results]); + return; + } else { + NSLog(@"Error getting sexual activity samples: %@", error); + callback(@[RCTMakeError(@"Error getting sexual activity samples", error, nil)]); + return; + } + }]; + +} + +@end diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.h b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.h index 357aa895..1842610a 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.h +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.h @@ -11,38 +11,49 @@ @interface RCTAppleHealthKit (Queries) -- (void)fetchMostRecentQuantitySampleOfType:(HKQuantityType *)quantityType predicate:(NSPredicate *)predicate completion:(void (^)(HKQuantity *mostRecentQuantity, NSDate *startDate, NSDate *endDate, NSError *error))completion; -- (void)fetchSumOfSamplesTodayForType:(HKQuantityType *)quantityType unit:(HKUnit *)unit completion:(void (^)(double, NSError *))completionHandler; -- (void)fetchSumOfSamplesOnDayForType:(HKQuantityType *)quantityType unit:(HKUnit *)unit day:(NSDate *)day completion:(void (^)(double, NSDate *, NSDate *, NSError *))completionHandler; +- (void)fetchMostRecentQuantitySampleOfType:(HKQuantityType *)quantityType + predicate:(NSPredicate *)predicate + completion:(void (^)(HKQuantity *mostRecentQuantity, NSDate *startDate, NSDate *endDate, NSError *error))completion; + +- (void)fetchSumOfSamplesTodayForType:(HKQuantityType *)quantityType + unit:(HKUnit *)unit + completion:(void (^)(double, NSError *))completionHandler; + +- (void)fetchSumOfSamplesOnDayForType:(HKQuantityType *)quantityType + unit:(HKUnit *)unit + day:(NSDate *)day + completion:(void (^)(double, NSDate *, NSDate *, NSError *))completionHandler; + - (void)fetchCumulativeSumStatisticsCollection:(HKQuantityType *)quantityType unit:(HKUnit *)unit startDate:(NSDate *)startDate endDate:(NSDate *)endDate completion:(void (^)(NSArray *, NSError *))completionHandler; - - (void)fetchSamplesOfType:(HKSampleType *)quantityType - unit:(HKUnit *)unit - predicate:(NSPredicate *)predicate - ascending:(BOOL)asc - limit:(NSUInteger)lim - completion:(void (^)(NSArray *, NSError *))completion; + unit:(HKUnit *)unit + predicate:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)lim + completion:(void (^)(NSArray *, NSError *))completion; + - (void)setObserverForType:(HKSampleType *)quantityType unit:(HKUnit *)unit; - - (void)fetchQuantitySamplesOfType:(HKQuantityType *)quantityType unit:(HKUnit *)unit predicate:(NSPredicate *)predicate ascending:(BOOL)asc limit:(NSUInteger)lim completion:(void (^)(NSArray *, NSError *))completion; + - (void)fetchCorrelationSamplesOfType:(HKQuantityType *)quantityType unit:(HKUnit *)unit predicate:(NSPredicate *)predicate ascending:(BOOL)asc limit:(NSUInteger)lim completion:(void (^)(NSArray *, NSError *))completion; + - (void)fetchCumulativeSumStatisticsCollection:(HKQuantityType *)quantityType unit:(HKUnit *)unit startDate:(NSDate *)startDate @@ -50,19 +61,34 @@ ascending:(BOOL)asc limit:(NSUInteger)lim completion:(void (^)(NSArray *, NSError *))completionHandler; + - (void)fetchCumulativeSumStatisticsCollection:(HKQuantityType *)quantityType unit:(HKUnit *)unit - period:(NSUInteger)period + period:(NSUInteger)period startDate:(NSDate *)startDate endDate:(NSDate *)endDate ascending:(BOOL)asc limit:(NSUInteger)lim - includeManuallyAdded:(BOOL)includeManuallyAdded + includeManuallyAdded:(BOOL)includeManuallyAdded completion:(void (^)(NSArray *, NSError *))completionHandler; - - (void)fetchSleepCategorySamplesForPredicate:(NSPredicate *)predicate - limit:(NSUInteger)lim + limit:(NSUInteger)lim completion:(void (^)(NSArray *, NSError *))completion; +- (void)fetchMenstruationFlowSamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)lim + completion:(void (^)(NSArray *, NSError *))completion; + +- (void)fetchSexualActivitySamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)lim + completion:(void (^)(NSArray *, NSError *))completion; + +- (void)fetchOvulationTestResultSamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)lim + completion:(void (^)(NSArray *, NSError *))completion; + @end diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m index 325493bd..428d9e9b 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m @@ -651,4 +651,169 @@ - (void)fetchCumulativeSumStatisticsCollection:(HKQuantityType *)quantityType [self.healthStore executeQuery:query]; } +- (void)fetchMenstruationFlowSamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)limit + completion:(void (^)(NSArray *, NSError *))completion { + + void (^handlerBlock)(HKSampleQuery *query, NSArray *results, NSError *error) + = ^(HKSampleQuery *query, NSArray *results, NSError *error) { + if (!results) { + if (completion) { + completion(nil, error); + } + return; + } + + if (completion) { + NSMutableArray *data = [NSMutableArray arrayWithCapacity:1]; + + dispatch_async(dispatch_get_main_queue(), ^{ + for (HKCategorySample *sample in results) { + NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate]; + NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate]; + bool isTracked = [[sample metadata][HKMetadataKeyWasUserEntered] intValue] == 1; + + NSDictionary *elem = @{ + @"endDate" : endDateString, + @"sourceId" : [[[sample sourceRevision] source] bundleIdentifier], + @"sourceName" : [[[sample sourceRevision] source] name], + @"startDate" : startDateString, + @"tracked" : @(isTracked), + @"value" : @(sample.value), + }; + + [data addObject:elem]; + } + + completion(data, error); + }); + } + }; + + HKSampleType *sampleType = [HKCategoryType categoryTypeForIdentifier: HKCategoryTypeIdentifierMenstrualFlow]; + + NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate + ascending:asc]; + + HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:sampleType + predicate:predicate + limit:limit + sortDescriptors:@[timeSortDescriptor] + resultsHandler:handlerBlock]; + + [self.healthStore executeQuery:query]; +} + +- (void)fetchOvulationTestResultSamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)limit + completion:(void (^)(NSArray *, NSError *))completion { + + void (^handlerBlock)(HKSampleQuery *query, NSArray *results, NSError *error) + = ^(HKSampleQuery *query, NSArray *results, NSError *error) { + if (!results) { + if (completion) { + completion(nil, error); + } + return; + } + + if (completion) { + NSMutableArray *data = [NSMutableArray arrayWithCapacity:1]; + + dispatch_async(dispatch_get_main_queue(), ^{ + for (HKCategorySample *sample in results) { + NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate]; + NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate]; + bool isTracked = [[sample metadata][HKMetadataKeyWasUserEntered] intValue] == 1; + + NSDictionary *elem = @{ + @"endDate" : endDateString, + @"sourceId" : [[[sample sourceRevision] source] bundleIdentifier], + @"sourceName" : [[[sample sourceRevision] source] name], + @"startDate" : startDateString, + @"tracked" : @(isTracked), + @"value" : @(sample.value), + }; + + [data addObject:elem]; + } + + completion(data, error); + }); + } + }; + + HKSampleType *sampleType = [HKCategoryType categoryTypeForIdentifier: HKCategoryTypeIdentifierOvulationTestResult]; + + NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate + ascending:asc]; + + HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:sampleType + predicate:predicate + limit:limit + sortDescriptors:@[timeSortDescriptor] + resultsHandler:handlerBlock]; + + [self.healthStore executeQuery:query]; +} + +- (void)fetchSexualActivitySamples:(NSPredicate *)predicate + ascending:(BOOL)asc + limit:(NSUInteger)limit + completion:(void (^)(NSArray *, NSError *))completion { + + void (^handlerBlock)(HKSampleQuery *query, NSArray *results, NSError *error) + = ^(HKSampleQuery *query, NSArray *results, NSError *error) { + if (!results) { + if (completion) { + completion(nil, error); + } + return; + } + + if (completion) { + NSMutableArray *data = [NSMutableArray arrayWithCapacity:1]; + + dispatch_async(dispatch_get_main_queue(), ^{ + for (HKCategorySample *sample in results) { + NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate]; + NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate]; + bool isTracked = [[sample metadata][HKMetadataKeyWasUserEntered] intValue] == 1; + int protectionUsed = [[sample metadata][HKMetadataKeySexualActivityProtectionUsed] intValue]; + + NSDictionary *elem = @{ + @"endDate" : endDateString, + @"protectionUsed" : @(protectionUsed), + @"sourceId" : [[[sample sourceRevision] source] bundleIdentifier], + @"sourceName" : [[[sample sourceRevision] source] name], + @"startDate" : startDateString, + @"tracked" : @(isTracked), + @"value" : @(sample.value), + }; + + [data addObject:elem]; + } + + completion(data, error); + }); + } + }; + + HKSampleType *sampleType = [HKCategoryType categoryTypeForIdentifier: HKCategoryTypeIdentifierSexualActivity]; + + NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate + ascending:asc]; + + HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:sampleType + predicate:predicate + limit:limit + sortDescriptors:@[timeSortDescriptor] + resultsHandler:handlerBlock]; + + [self.healthStore executeQuery:query]; +} + + @end diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m index 50c8b339..2e235a7e 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m @@ -54,7 +54,7 @@ - (NSDictionary *)readPermsDict { //workouts @"Workout" : [HKObjectType workoutType], // Reproductive Health - @"BasalBodyTemperature" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSexualActivity], + @"BasalBodyTemperature" : [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBasalBodyTemperature], @"MenstruationFlow" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierMenstrualFlow], @"OvulationTestResult" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierOvulationTestResult], @"SexualActivity" : [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSexualActivity], diff --git a/RCTAppleHealthKit/RCTAppleHealthKit.m b/RCTAppleHealthKit/RCTAppleHealthKit.m index e2b13587..0ef961c8 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit.m @@ -12,13 +12,14 @@ #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_Dietary.h" +#import "RCTAppleHealthKit+Methods_Fitness.h" +#import "RCTAppleHealthKit+Methods_Mindfulness.h" +#import "RCTAppleHealthKit+Methods_ReproductiveHealth.h" #import "RCTAppleHealthKit+Methods_Results.h" #import "RCTAppleHealthKit+Methods_Sleep.h" -#import "RCTAppleHealthKit+Methods_Mindfulness.h" +#import "RCTAppleHealthKit+Methods_Vitals.h" #import #import @@ -245,6 +246,26 @@ @implementation RCTAppleHealthKit [self mindfulness_saveMindfulSession:input callback:callback]; } +RCT_EXPORT_METHOD(getBasalBodyTemperatureSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) +{ + [self reproductiveHealth_getBasalBodyTemperatureSamples:input callback:callback]; +} + +RCT_EXPORT_METHOD(getMenstruationFlowSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) +{ + [self reproductiveHealth_getMenstruationFlowSamples:input callback:callback]; +} + +RCT_EXPORT_METHOD(getOvulationTestResultSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) +{ + [self reproductiveHealth_getOvulationTestResultSamples:input callback:callback]; +} + +RCT_EXPORT_METHOD(getSexualActivitySamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) +{ + [self reproductiveHealth_getSexualActivitySamples:input callback:callback]; +} + - (void)isHealthKitAvailable:(RCTResponseSenderBlock)callback { From 5cb45f6c0a8c4bb442e1ad0f2d2ec8aacc37a2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 16:27:40 +0200 Subject: [PATCH 6/9] Added docs --- README.md | 20 ++++++++++++++------ docs/getBasalBodyTemperatureSamples().md | 17 +++++++++++++++++ docs/getMenstruationFlowSamples().md | 16 ++++++++++++++++ docs/getOvulationTestResultSamples().md | 16 ++++++++++++++++ docs/getSexualActivitySamples().md | 16 ++++++++++++++++ 5 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 docs/getBasalBodyTemperatureSamples().md create mode 100644 docs/getMenstruationFlowSamples().md create mode 100644 docs/getOvulationTestResultSamples().md create mode 100644 docs/getSexualActivitySamples().md diff --git a/README.md b/README.md index 6ad3ead0..c0b24956 100644 --- a/README.md +++ b/README.md @@ -112,10 +112,12 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => * [setObserver](/docs/setObserver().md) * Read Methods * [getActiveEnergyBurned](/docs/getActiveEnergyBurned().md) + * [getBasalBodyTemperatureSamples](/docs/getBasalBodyTemperatureSamples().md) * [getBasalEnergyBurned](/docs/getBasalEnergyBurned().md) * [getBiologicalSex](/docs/getBiologicalSex().md) * [getBloodGlucoseSamples](/docs/getBloodglucoseSamples().md) * [getBloodPressureSamples](/docs/getBloodPressureSamples().md) + * [getBodyFatPercentageSamples](/docs/getBodyFatPercentageSamples().md) * [getBodyTemperatureSamples](/docs/getBodyTemperatureSamples().md) * [getDailyDistanceCyclingSamples](/docs/getDailyDistanceCyclingSamples().md) * [getDailyDistanceWalkingRunningSamples](/docs/getDailyDistanceWalkingRunningSamples().md) @@ -130,16 +132,18 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => * [getHeightSamples](/docs/getHeightSamples().md) * [getLatestBmi](/docs/getLatestBmi().md) * [getLatestBodyFatPercentage](/docs/getLatestBodyFatPercentage().md) - * [getBodyFatPercentageSamples](/docs/getBodyFatPercentageSamples().md) * [getLatestHeight](/docs/getLatestHeight().md) * [getLatestLeanBodyMass](/docs/getLatestLeanBodyMass().md) - * [getLeanBodyMassSamples](/docs/getLeanBodyMassSamples().md) * [getLatestWeight](/docs/getLatestWeight().md) + * [getLeanBodyMassSamples](/docs/getLeanBodyMassSamples().md) + * [getMenstruationFlowSamples](/docs/getMenstruationFlowSamples().md) + * [getOvulationTestResultSamples](/docs/getOvulationTestResultSamples().md) * [getRespiratoryRateSamples](/docs/getRespiratoryRateSamples().md) + * [getSamples](docs/getSamples().md) + * [getSexualActivitySamples](/docs/getSexualActivitySamples().md) * [getSleepSamples](/docs/getSleepSamples().md) * [getStepCount](/docs/getStepCount().md) * [getWeightSamples](/docs/getWeightSamples().md) - * [getSamples](docs/getSamples().md) * Write Methods * [saveBmi](/docs/saveBmi().md) * [saveHeight](/docs/saveHeight().md) @@ -156,12 +160,14 @@ The available Healthkit permissions to use with `initHealthKit` | Permission | Healthkit Identifier Type | Read | Write | |------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|-------| -| ActiveEnergyBurned | [HKQuantityTypeIdentifierActiveEnergyBurned](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/1615771-activeenergyburned?language=objc) | ✓ | | -| BasalEnergyBurned | [HKQuantityTypeIdentifierBasalEnergyBurned](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/1615512-basalenergyburned?language=objc) | ✓ | | +| ActiveEnergyBurned | [HKQuantityTypeIdentifierActiveEnergyBurned](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/1615771-activeenergyburned?language=objc)| ✓ | | +| BasalBodyTemperature | [HKQuantityTypeIdentifierBasalBodyTemperature](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbasalbodytemperature?language=objc) | ✓ | | +| BasalEnergyBurned | [HKQuantityTypeIdentifierBasalEnergyBurned](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier/1615512-basalenergyburned?language=objc) | ✓ | | | BiologicalSex | [HKCharacteristicTypeIdentifierBiologicalSex](https://developer.apple.com/reference/Healthkit/hkcharacteristictypeidentifierbiologicalsex?language=objc) | ✓ | | | BloodGlucose | [HKQuantityTypeIdentifierBloodGlucose](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbloodglucose?language=objc) | ✓ | | | BloodPressureDiastolic | [HKQuantityTypeIdentifierBloodPressureDiastolic](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbloodpressurediastolic?language=objc) | ✓ | ✓ | | BloodPressureSystolic | [HKQuantityTypeIdentifierBloodPressureSystolic](https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbloodpressuresystolic?language=objc) | ✓ | ✓ | +| BodyFatPercentage | [HKQuantityTypeIdentifierBodyFatPercentage](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbodyfatpercentage?language=objc) | ✓ | ✓ | | BodyMassIndex | [HKQuantityTypeIdentifierBodyMassIndex](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbodymassindex?language=objc) | ✓ | ✓ | | BodyTemperature | [HKQuantityTypeIdentifierBodyTemperature](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbodytemperature?language=objc) | ✓ | | | DateOfBirth | [HKCharacteristicTypeIdentifierDateOfBirth](https://developer.apple.com/reference/Healthkit/hkcharacteristictypeidentifierdateofbirth?language=objc) | ✓ | | @@ -171,13 +177,15 @@ The available Healthkit permissions to use with `initHealthKit` | HeartRate | [HKQuantityTypeIdentifierHeartRate](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierheartrate?language=objc) | ✓ | | | Height | [HKQuantityTypeIdentifierHeight](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierheight?language=objc) | ✓ | ✓ | | LeanBodyMass | [HKQuantityTypeIdentifierLeanBodyMass](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierleanbodymass?language=objc) | ✓ | ✓ | +| MenstruationFlow | [HKCategoryTypeIdentifierMenstrualFlow](https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifiermenstrualflow?language=occ) | ✓ | | | MindfulSession | [HKCategoryTypeIdentifierMindfulSession](https://developer.apple.com/reference/healthkit/hkcategorytypeidentifiermindfulsession?language=objc) | | ✓ | +| OvulationTestResult | [HKCategoryTypeIdentifierOvulationTestResult](https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierovulationtestresult?language=occ) | ✓ | | | RespiratoryRate | [HKQuantityTypeIdentifierRespiratoryRate](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierrespiratoryrate?language=objc) | ✓ | | +| SexualActivity | [HKCategoryTypeIdentifierSexualActivity](https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifiersexualactivity?language=occ) | ✓ | | | SleepAnalysis | [HKCategoryTypeIdentifierSleepAnalysis](https://developer.apple.com/reference/Healthkit/hkcategorytypeidentifiersleepanalysis?language=objc) | ✓ | | | StepCount | [HKQuantityTypeIdentifierStepCount](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierstepcount?language=objc) | ✓ | ✓ | | Steps | [HKQuantityTypeIdentifierSteps](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifiersteps?language=objc) | ✓ | ✓ | | Weight | [HKQuantityTypeIdentifierBodyMass](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbodymass?language=objc) | ✓ | ✓ | -| BodyFatPercentage | [HKQuantityTypeIdentifierBodyFatPercentage](https://developer.apple.com/reference/Healthkit/hkquantitytypeidentifierbodyfatpercentage?language=objc) | ✓ | ✓ | These permissions are exported as constants of the `rn-apple-healthkit` module. diff --git a/docs/getBasalBodyTemperatureSamples().md b/docs/getBasalBodyTemperatureSamples().md new file mode 100644 index 00000000..cdbc7dd9 --- /dev/null +++ b/docs/getBasalBodyTemperatureSamples().md @@ -0,0 +1,17 @@ +```javascript +let options = { + ascending: 'celsius', // optional; default true + endDate: new Date().toISOString(), // optional; default now + startDate: new Date(2019, 06, 21).toISOString(), // required + unit: 'celsius' // optional; default 'celsius' +}; +``` + +```javascript +AppleHealthKit.getBasalBodyTemperatureSamples(options: Object, (error: Object, results: Object) => { + if (error) { + console.error(error.message); + } + console.log(results); +}); +``` diff --git a/docs/getMenstruationFlowSamples().md b/docs/getMenstruationFlowSamples().md new file mode 100644 index 00000000..a7d56cdc --- /dev/null +++ b/docs/getMenstruationFlowSamples().md @@ -0,0 +1,16 @@ +```javascript +let options = { + ascending: 'celsius', // optional; default true + endDate: new Date().toISOString(), // optional; default now + startDate: new Date(2019, 06, 21).toISOString() // required +}; +``` + +```javascript +AppleHealthKit.getMenstruationFlowSamples(options: Object, (error: Object, results: Object) => { + if (error) { + console.error(error.message); + } + console.log(results); +}); +``` diff --git a/docs/getOvulationTestResultSamples().md b/docs/getOvulationTestResultSamples().md new file mode 100644 index 00000000..bdc232d8 --- /dev/null +++ b/docs/getOvulationTestResultSamples().md @@ -0,0 +1,16 @@ +```javascript +let options = { + ascending: 'celsius', // optional; default true + endDate: new Date().toISOString(), // optional; default now + startDate: new Date(2019, 06, 21).toISOString() // required +}; +``` + +```javascript +AppleHealthKit.getOvulationTestResultSamples(options: Object, (error: Object, results: Object) => { + if (error) { + console.error(error.message); + } + console.log(results); +}); +``` diff --git a/docs/getSexualActivitySamples().md b/docs/getSexualActivitySamples().md new file mode 100644 index 00000000..b87fd252 --- /dev/null +++ b/docs/getSexualActivitySamples().md @@ -0,0 +1,16 @@ +```javascript +let options = { + ascending: 'celsius', // optional; default true + endDate: new Date().toISOString(), // optional; default now + startDate: new Date(2019, 06, 21).toISOString() // required +}; +``` + +```javascript +AppleHealthKit.getSexualActivitySamples(options: Object, (error: Object, results: Object) => { + if (error) { + console.error(error.message); + } + console.log(results); +}); +``` From c9aba4e289762bcd64b55304a736fb53cc231e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 16:30:37 +0200 Subject: [PATCH 7/9] Fixed typo in docs --- docs/getBasalBodyTemperatureSamples().md | 2 +- docs/getMenstruationFlowSamples().md | 2 +- docs/getOvulationTestResultSamples().md | 2 +- docs/getSexualActivitySamples().md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/getBasalBodyTemperatureSamples().md b/docs/getBasalBodyTemperatureSamples().md index cdbc7dd9..a95ecb0e 100644 --- a/docs/getBasalBodyTemperatureSamples().md +++ b/docs/getBasalBodyTemperatureSamples().md @@ -1,6 +1,6 @@ ```javascript let options = { - ascending: 'celsius', // optional; default true + ascending: true, // optional; default true endDate: new Date().toISOString(), // optional; default now startDate: new Date(2019, 06, 21).toISOString(), // required unit: 'celsius' // optional; default 'celsius' diff --git a/docs/getMenstruationFlowSamples().md b/docs/getMenstruationFlowSamples().md index a7d56cdc..3e9f139b 100644 --- a/docs/getMenstruationFlowSamples().md +++ b/docs/getMenstruationFlowSamples().md @@ -1,6 +1,6 @@ ```javascript let options = { - ascending: 'celsius', // optional; default true + ascending: true, // optional; default true endDate: new Date().toISOString(), // optional; default now startDate: new Date(2019, 06, 21).toISOString() // required }; diff --git a/docs/getOvulationTestResultSamples().md b/docs/getOvulationTestResultSamples().md index bdc232d8..980e5b22 100644 --- a/docs/getOvulationTestResultSamples().md +++ b/docs/getOvulationTestResultSamples().md @@ -1,6 +1,6 @@ ```javascript let options = { - ascending: 'celsius', // optional; default true + ascending: true, // optional; default true endDate: new Date().toISOString(), // optional; default now startDate: new Date(2019, 06, 21).toISOString() // required }; diff --git a/docs/getSexualActivitySamples().md b/docs/getSexualActivitySamples().md index b87fd252..0bb8d7d5 100644 --- a/docs/getSexualActivitySamples().md +++ b/docs/getSexualActivitySamples().md @@ -1,6 +1,6 @@ ```javascript let options = { - ascending: 'celsius', // optional; default true + ascending: true, // optional; default true endDate: new Date().toISOString(), // optional; default now startDate: new Date(2019, 06, 21).toISOString() // required }; From 7faacb3c222058c14c7428c3c816748d9185c953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 16:36:05 +0200 Subject: [PATCH 8/9] Reformatted with XCode --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index a394e5ae..681f10c2 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -20,9 +20,9 @@ 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; }; 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; }; 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; }; + B790AE8A22E5CCDE00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m in Sources */ = {isa = PBXBuildFile; fileRef = B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */; }; B79BEDD622E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m in Sources */ = {isa = PBXBuildFile; fileRef = B79BEDD422E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m */; }; - B790AE8A22E5CCDE00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m in Sources */ = {isa = PBXBuildFile; fileRef = B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */; }; - /* End PBXBuildFile section */ +/* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 3774C88B1D2092F20000B3F3 /* CopyFiles */ = { @@ -63,11 +63,11 @@ 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = ""; }; 64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = ""; }; 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = ""; }; + B790AE8822E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.h"; sourceTree = ""; }; + B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.m"; sourceTree = ""; }; B79BEDD422E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Dietary.m"; sourceTree = ""; }; B79BEDD522E5AAFA008B6A34 /* RCTAppleHealthKit+Methods_Dietary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Dietary.h"; sourceTree = ""; }; - B790AE8822E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.h"; sourceTree = ""; }; - B790AE8922E5CCDD00F333FF /* RCTAppleHealthKit+Methods_ReproductiveHealth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_ReproductiveHealth.m"; sourceTree = ""; }; - /* End PBXFileReference section */ +/* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 3774C88A1D2092F20000B3F3 /* Frameworks */ = { From 403c2b04da88c0ae9bea1441b925c4aa768c5d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Miguel=20Cruz=20Cana?= Date: Tue, 23 Jul 2019 16:36:48 +0200 Subject: [PATCH 9/9] Removed automatically added language --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index 681f10c2..efaad6f0 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -170,7 +170,6 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - English, en, ); mainGroup = 3774C8841D2092F20000B3F3;