Skip to content

Commit ba27710

Browse files
authored
Merge branch 'master' into feature/peak-flow
2 parents cf3d46b + 0b57e9d commit ba27710

File tree

80 files changed

+5561
-2699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5561
-2699
lines changed

.github/auto_assign.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

RCTAppleHealthKit.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; };
2323
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; };
2424
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; };
25+
8C640F40269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */; };
26+
8C79D960268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */; };
2527
/* End PBXBuildFile section */
2628

2729
/* Begin PBXCopyFilesBuildPhase section */
@@ -38,6 +40,8 @@
3840
/* End PBXCopyFilesBuildPhase section */
3941

4042
/* Begin PBXFileReference section */
43+
27B60163269770030034AB4E /* RCTAppleHealthKit+Methods_Summary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Summary.h"; sourceTree = "<group>"; };
44+
27B60164269770850034AB4E /* RCTAppleHealthKit+Methods_Summary.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Summary.m"; sourceTree = "<group>"; };
4145
358330DD20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Workout.h"; sourceTree = "<group>"; };
4246
358330DE20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Workout.m"; sourceTree = "<group>"; };
4347
3774C88D1D2092F20000B3F3 /* libRCTAppleHealthKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAppleHealthKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -67,6 +71,10 @@
6771
64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = "<group>"; };
6872
64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = "<group>"; };
6973
64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = "<group>"; };
74+
8C640F3E269DF680004CAFED /* RCTAppleHealthKit+Methods_Hearing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Hearing.h"; sourceTree = "<group>"; };
75+
8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Hearing.m"; sourceTree = "<group>"; };
76+
8C79D95E268E07DB00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_ClinicalRecords.h"; sourceTree = "<group>"; };
77+
8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_ClinicalRecords.m"; sourceTree = "<group>"; };
7078
/* End PBXFileReference section */
7179

7280
/* Begin PBXFrameworksBuildPhase section */
@@ -127,6 +135,12 @@
127135
37837E7C1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m */,
128136
358330DD20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.h */,
129137
358330DE20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m */,
138+
8C640F3E269DF680004CAFED /* RCTAppleHealthKit+Methods_Hearing.h */,
139+
8C640F3F269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m */,
140+
27B60163269770030034AB4E /* RCTAppleHealthKit+Methods_Summary.h */,
141+
27B60164269770850034AB4E /* RCTAppleHealthKit+Methods_Summary.m */,
142+
8C79D95E268E07DB00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.h */,
143+
8C79D95F268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m */,
130144
);
131145
path = RCTAppleHealthKit;
132146
sourceTree = "<group>";
@@ -190,12 +204,14 @@
190204
files = (
191205
3774C89B1D2095450000B3F3 /* RCTAppleHealthKit+Queries.m in Sources */,
192206
3774C8A11D20A6B90000B3F3 /* RCTAppleHealthKit+Utils.m in Sources */,
207+
8C640F40269DF69C004CAFED /* RCTAppleHealthKit+Methods_Hearing.m in Sources */,
193208
37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */,
194209
3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */,
195210
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */,
196211
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */,
197212
358330DF20931B8A000F0B94 /* RCTAppleHealthKit+Methods_Workout.m in Sources */,
198213
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */,
214+
8C79D960268E081A00DBDC40 /* RCTAppleHealthKit+Methods_ClinicalRecords.m in Sources */,
199215
3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */,
200216
377D44F31D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.m in Sources */,
201217
4F8095C92523C39D00A84ADB /* RCTAppleHealthKit+Methods_LabTests.m in Sources */,

RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- (void)body_saveWeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1616

1717
- (void)body_getLatestBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
18+
- (void)body_getBodyMassIndexSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1819
- (void)body_saveBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1920

2021
- (void)body_getLatestHeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;

RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,37 @@ - (void)body_getLatestBodyMassIndex:(NSDictionary *)input callback:(RCTResponseS
118118
}];
119119
}
120120

121+
- (void)body_getBodyMassIndexSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
122+
{
123+
HKQuantityType *bmiType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMassIndex];
124+
125+
HKUnit *countUnit = [HKUnit countUnit];
126+
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
127+
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
128+
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
129+
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
130+
if(startDate == nil){
131+
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
132+
return;
133+
}
134+
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];
135+
136+
[self fetchQuantitySamplesOfType:bmiType
137+
unit:countUnit
138+
predicate:predicate
139+
ascending:ascending
140+
limit:limit
141+
completion:^(NSArray *results, NSError *error) {
142+
if(results){
143+
callback(@[[NSNull null], results]);
144+
return;
145+
} else {
146+
callback(@[RCTJSErrorFromNSError(error)]);
147+
return;
148+
}
149+
}];
150+
}
151+
121152

122153
- (void)body_saveBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
123154
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// RCTAppleHealthKit+Methods_ClinicalRecords.h
3+
// RCTAppleHealthKit
4+
//
5+
// This source code is licensed under the MIT-style license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
8+
#import "RCTAppleHealthKit.h"
9+
10+
@interface RCTAppleHealthKit (Methods_ClinicalRecords)
11+
12+
- (void)clinicalRecords_getClinicalRecords:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
13+
- (void)clinical_registerObserver:(NSString *)type bridge:(RCTBridge *)bridge hasListeners:(bool)hasListeners;
14+
15+
@end
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// RCTAppleHealthKit+Methods_ClinicalRecords.m
3+
// RCTAppleHealthKit
4+
//
5+
// This source code is licensed under the MIT-style license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
8+
#import "RCTAppleHealthKit+Methods_ClinicalRecords.h"
9+
#import "RCTAppleHealthKit+Queries.h"
10+
#import "RCTAppleHealthKit+Utils.h"
11+
12+
@implementation RCTAppleHealthKit (Methods_ClinicalRecords)
13+
14+
- (void)clinicalRecords_getClinicalRecords:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
15+
{
16+
NSString *type = [RCTAppleHealthKit stringFromOptions:input key:@"type" withDefault:nil];
17+
if(type == nil){
18+
callback(@[RCTMakeError(@"type is required in options", nil, nil)]);
19+
return;
20+
}
21+
22+
if (
23+
![type isEqual:@"AllergyRecord"] &&
24+
![type isEqual:@"ConditionRecord"] &&
25+
![type isEqual:@"CoverageRecord"] &&
26+
![type isEqual:@"ImmunizationRecord"] &&
27+
![type isEqual:@"LabResultRecord"] &&
28+
![type isEqual:@"MedicationRecord"] &&
29+
![type isEqual:@"ProcedureRecord"] &&
30+
![type isEqual:@"VitalSignRecord"]
31+
) {
32+
callback(@[RCTMakeError(@"invalid type, type must be one of 'AllergyRecord'|'ConditionRecord'|'CoverageRecord'|'ImmunizationRecord'|'LabResultRecord'|'MedicationRecord'|'ProcedureRecord'|'VitalSignRecord'", nil, nil)]);
33+
return;
34+
}
35+
36+
HKObjectType *recordType = [RCTAppleHealthKit clinicalTypeFromName:type];
37+
if (recordType == nil) {
38+
callback(@[RCTMakeError(@"the requested clinical record type is not available for this iOS version", nil, nil)]);
39+
return;
40+
}
41+
42+
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
43+
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
44+
45+
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
46+
if(startDate == nil){
47+
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
48+
return;
49+
}
50+
51+
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
52+
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];
53+
54+
[self fetchClinicalRecordsOfType:recordType predicate:predicate ascending:ascending limit:limit completion:^(NSArray *results, NSError *error) {
55+
if(results){
56+
callback(@[[NSNull null], results]);
57+
return;
58+
} else {
59+
callback(@[RCTJSErrorFromNSError(error)]);
60+
return;
61+
}
62+
}];
63+
}
64+
65+
- (void)clinical_registerObserver:(NSString *)type bridge:(RCTBridge *)bridge hasListeners:(bool)hasListeners
66+
{
67+
HKSampleType *recordType = [RCTAppleHealthKit clinicalTypeFromName:type];
68+
if (recordType != nil) {
69+
[self setObserverForType:recordType type:type bridge:bridge hasListeners:hasListeners];
70+
}
71+
}
72+
73+
@end

RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
- (void)saveWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1616
- (void)getWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
17+
- (void)getWaterSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1718

1819
- (void)dietary_getEnergyConsumedSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1920
- (void)dietary_getProteinSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
21+
- (void)dietary_getTotalFatSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
2022
@end

RCTAppleHealthKit/RCTAppleHealthKit+Methods_Dietary.m

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,37 @@ - (void)dietary_getEnergyConsumedSamples:(NSDictionary *)input callback:(RCTResp
4646
}];
4747
}
4848

49+
- (void)dietary_getTotalFatSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
50+
{
51+
HKQuantityType *fatTotalType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryFatTotal];
52+
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit gramUnit]];
53+
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
54+
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
55+
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
56+
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
57+
if(startDate == nil){
58+
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
59+
return;
60+
}
61+
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];
62+
63+
[self fetchQuantitySamplesOfType:fatTotalType
64+
unit:unit
65+
predicate:predicate
66+
ascending:ascending
67+
limit:limit
68+
completion:^(NSArray *results, NSError *error) {
69+
if(results){
70+
callback(@[[NSNull null], results]);
71+
return;
72+
} else {
73+
NSLog(@"An error occured while retrieving the total fat sample %@. The error was: ", error);
74+
callback(@[RCTMakeError(@"An error occured while retrieving the total fat sample", error, nil)]);
75+
return;
76+
}
77+
}];
78+
}
79+
4980
- (void)dietary_getProteinSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
5081
{
5182
HKQuantityType *proteinType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryProtein];
@@ -502,4 +533,39 @@ - (void)getWater:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
502533
}];
503534
}
504535

536+
- (void)getWaterSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
537+
{
538+
HKQuantityType *dietaryWaterType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietaryWater];
539+
HKUnit *literUnit = [HKUnit literUnit];
540+
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
541+
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
542+
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
543+
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
544+
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:true];
545+
546+
547+
if(startDate == nil) {
548+
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
549+
return;
550+
}
551+
552+
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];
553+
554+
[self fetchQuantitySamplesOfType:dietaryWaterType
555+
unit:literUnit
556+
predicate:predicate
557+
ascending:ascending
558+
limit:limit
559+
completion:^(NSArray *results, NSError *error) {
560+
if(results){
561+
callback(@[[NSNull null], results]);
562+
return;
563+
} else {
564+
NSLog(@"An error occured while retrieving the water sample %@. The error was: ", error);
565+
callback(@[RCTMakeError(@"An error occured while retrieving the water sample", error, nil)]);
566+
return;
567+
}
568+
}];
569+
}
570+
505571
@end

RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
- (void)fitness_getSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1515
- (void)fitness_getDailyStepSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1616
- (void)fitness_saveSteps:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
17-
- (void)fitness_initializeStepEventObserver:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
17+
- (void)fitness_saveWalkingRunningDistance:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
18+
- (void)fitness_initializeStepEventObserver:(NSDictionary *)input hasListeners:(bool)hasListeners callback:(RCTResponseSenderBlock)callback;
1819
- (void)fitness_getDistanceWalkingRunningOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
1920
- (void)fitness_getDailyDistanceWalkingRunningSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
2021
- (void)fitness_getDistanceSwimmingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
@@ -26,6 +27,7 @@
2627

2728
- (void)fitness_setObserver:(NSDictionary *)input __deprecated;
2829
- (void)fitness_registerObserver:(NSString *)type
29-
bridge:(RCTBridge *)bridge;
30+
bridge:(RCTBridge *)bridge
31+
hasListeners:(bool)hasListeners;
3032

3133
@end

0 commit comments

Comments
 (0)