Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rn-apple-healthkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ym
rn-apple-healthkit
Commits
d5f10e70
Commit
d5f10e70
authored
Jun 29, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pre-0.1.0'
parents
cd29c076
53cce868
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
445 additions
and
54 deletions
+445
-54
RCTAppleHealthKit.xcodeproj/project.pbxproj
RCTAppleHealthKit.xcodeproj/project.pbxproj
+7
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
+2
-1
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
+71
-6
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
+16
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
+62
-0
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
+10
-0
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+63
-33
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
+7
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+102
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+21
-0
examples/BodyMeasurements/app/stores/body.js
examples/BodyMeasurements/app/stores/body.js
+72
-2
examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj
...asurements/ios/BodyMeasurements.xcodeproj/project.pbxproj
+12
-12
No files found.
RCTAppleHealthKit.xcodeproj/project.pbxproj
View file @
d5f10e70
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8A01D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m */
;
};
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8A01D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m */
;
};
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
;
};
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
;
};
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
;
};
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
;
};
377D44F31D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
;
};
/* End PBXBuildFile section */
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
/* Begin PBXCopyFilesBuildPhase section */
...
@@ -43,6 +44,8 @@
...
@@ -43,6 +44,8 @@
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Body.m"
;
sourceTree
=
"<group>"
;
};
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Body.m"
;
sourceTree
=
"<group>"
;
};
3774C8D51D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Fitness.h"
;
sourceTree
=
"<group>"
;
};
3774C8D51D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Fitness.h"
;
sourceTree
=
"<group>"
;
};
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Fitness.m"
;
sourceTree
=
"<group>"
;
};
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Fitness.m"
;
sourceTree
=
"<group>"
;
};
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.h"
;
sourceTree
=
"<group>"
;
};
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.m"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
/* Begin PBXFrameworksBuildPhase section */
...
@@ -87,6 +90,8 @@
...
@@ -87,6 +90,8 @@
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
,
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
,
3774C8D51D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.h */
,
3774C8D51D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.h */
,
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
,
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
,
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
,
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
,
);
);
path
=
RCTAppleHealthKit
;
path
=
RCTAppleHealthKit
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -151,6 +156,7 @@
...
@@ -151,6 +156,7 @@
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
,
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
,
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
,
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
,
3774C8931D2092F20000B3F3
/* RCTAppleHealthKit.m in Sources */
,
3774C8931D2092F20000B3F3
/* RCTAppleHealthKit.m in Sources */
,
377D44F31D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m in Sources */
,
3774C89E1D2095850000B3F3
/* RCTAppleHealthKit+TypesAndPermissions.m in Sources */
,
3774C89E1D2095850000B3F3
/* RCTAppleHealthKit+TypesAndPermissions.m in Sources */
,
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
,
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
,
);
);
...
@@ -286,6 +292,7 @@
...
@@ -286,6 +292,7 @@
3774C8981D2092F20000B3F3
/* Release */
,
3774C8981D2092F20000B3F3
/* Release */
,
);
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
};
/* End XCConfigurationList section */
/* End XCConfigurationList section */
};
};
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
View file @
d5f10e70
...
@@ -11,15 +11,16 @@
...
@@ -11,15 +11,16 @@
@interface
RCTAppleHealthKit
(
Methods_Body
)
@interface
RCTAppleHealthKit
(
Methods_Body
)
-
(
void
)
body_getCurrentWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getCurrentWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getWeightSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestBodyMassIndex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestBodyMassIndex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveBodyMassIndex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveBodyMassIndex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getHeightSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getMostRecentLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
View file @
d5f10e70
...
@@ -37,16 +37,46 @@
...
@@ -37,16 +37,46 @@
}
}
-
(
void
)
body_getWeightSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
weightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBodyMass
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
poundUnit
]];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
BOOL
ascending
=
[
RCTAppleHealthKit
boolFromOptions
:
input
key
:
@"ascending"
withDefault
:
false
];
NSDate
*
startDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
nil
];
NSDate
*
endDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"endDate"
withDefault
:
[
NSDate
date
]];
if
(
startDate
==
nil
){
callback
(@[
RCTMakeError
(
@"startDate is required in options"
,
nil
,
nil
)]);
return
;
}
NSPredicate
*
predicate
=
[
RCTAppleHealthKit
predicateForSamplesBetweenDates
:
startDate
endDate
:
endDate
];
[
self
fetchQuantitySamplesOfType
:
weightType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting weight samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting weight samples"
,
nil
,
nil
)]);
return
;
}
}];
}
-
(
void
)
body_saveWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
body_saveWeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
{
// double weight= [[input objectForKey:@"weight"] doubleValue];
double
weight
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
double
weight
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptionsDefaultNow
:
input
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptionsDefaultNow
:
input
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
poundUnit
]];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
];
if
(
unit
==
nil
){
unit
=
[
HKUnit
poundUnit
];
}
HKQuantity
*
weightQuantity
=
[
HKQuantity
quantityWithUnit
:
unit
doubleValue
:
weight
];
HKQuantity
*
weightQuantity
=
[
HKQuantity
quantityWithUnit
:
unit
doubleValue
:
weight
];
HKQuantityType
*
weightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBodyMass
];
HKQuantityType
*
weightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBodyMass
];
...
@@ -136,6 +166,41 @@
...
@@ -136,6 +166,41 @@
}
}
-
(
void
)
body_getHeightSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
heightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierHeight
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
inchUnit
]];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
BOOL
ascending
=
[
RCTAppleHealthKit
boolFromOptions
:
input
key
:
@"ascending"
withDefault
:
false
];
NSDate
*
startDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
nil
];
NSDate
*
endDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"endDate"
withDefault
:
[
NSDate
date
]];
if
(
startDate
==
nil
){
callback
(@[
RCTMakeError
(
@"startDate is required in options"
,
nil
,
nil
)]);
return
;
}
NSPredicate
*
predicate
=
[
RCTAppleHealthKit
predicateForSamplesBetweenDates
:
startDate
endDate
:
endDate
];
[
self
fetchQuantitySamplesOfType
:
heightType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting height samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting height samples"
,
nil
,
nil
)]);
return
;
}
}];
}
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
{
double
height
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
double
height
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
0 → 100644
View file @
d5f10e70
//
// RCTAppleHealthKit+Methods_Characteristic.h
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-29.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
@interface
RCTAppleHealthKit
(
Methods_Characteristic
)
-
(
void
)
characteristic_getBiologicalSex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
characteristic_getDateOfBirth
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
0 → 100644
View file @
d5f10e70
//
// RCTAppleHealthKit+Methods_Characteristic.m
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-29.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Methods_Characteristic.h"
#import "RCTAppleHealthKit+Utils.h"
@implementation
RCTAppleHealthKit
(
Methods_Characteristic
)
-
(
void
)
characteristic_getBiologicalSex
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
NSError
*
error
;
HKBiologicalSexObject
*
bioSex
=
[
self
.
healthStore
biologicalSexWithError
:
&
error
];
NSString
*
value
;
switch
(
bioSex
.
biologicalSex
)
{
case
HKBiologicalSexNotSet
:
value
=
@"unknown"
;
break
;
case
HKBiologicalSexFemale
:
value
=
@"female"
;
break
;
case
HKBiologicalSexMale
:
value
=
@"male"
;
break
;
case
HKBiologicalSexOther
:
value
=
@"other"
;
break
;
}
if
(
value
==
nil
){
NSLog
(
@"error getting biological sex: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting biological sex"
,
error
,
nil
)]);
return
;
}
callback
(@[[
NSNull
null
],
value
]);
}
-
(
void
)
characteristic_getDateOfBirth
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
NSError
*
error
;
NSDate
*
dob
=
[
self
.
healthStore
dateOfBirthWithError
:
&
error
];
if
(
error
!=
nil
){
NSLog
(
@"error getting date of birth: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting date of birth"
,
error
,
nil
)]);
return
;
}
NSString
*
dobString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
dob
];
callback
(@[[
NSNull
null
],
dobString
]);
}
@end
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
View file @
d5f10e70
...
@@ -19,4 +19,14 @@
...
@@ -19,4 +19,14 @@
startDate
:(
NSDate
*
)
startDate
startDate
:(
NSDate
*
)
startDate
endDate
:(
NSDate
*
)
endDate
endDate
:(
NSDate
*
)
endDate
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completionHandler
;
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completionHandler
;
-
(
void
)
fetchQuantitySamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
d5f10e70
...
@@ -12,8 +12,11 @@
...
@@ -12,8 +12,11 @@
@implementation
RCTAppleHealthKit
(
Queries
)
@implementation
RCTAppleHealthKit
(
Queries
)
-
(
void
)
fetchMostRecentQuantitySampleOfType
:(
HKQuantityType
*
)
quantityType
predicate
:(
NSPredicate
*
)
predicate
completion
:(
void
(
^
)(
HKQuantity
*
,
NSDate
*
,
NSDate
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending
:
NO
];
-
(
void
)
fetchMostRecentQuantitySampleOfType
:(
HKQuantityType
*
)
quantityType
predicate
:(
NSPredicate
*
)
predicate
completion
:(
void
(
^
)(
HKQuantity
*
,
NSDate
*
,
NSDate
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending
:
NO
];
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityType
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityType
predicate:
predicate
predicate:
predicate
limit:
1
limit:
1
...
@@ -41,6 +44,63 @@
...
@@ -41,6 +44,63 @@
-
(
void
)
fetchQuantitySamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending
:
asc
];
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityType
predicate:
predicate
limit:
lim
sortDescriptors:
@[
timeSortDescriptor
]
resultsHandler:
^
(
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
(
HKQuantitySample
*
sample
in
results
)
{
HKQuantity
*
quantity
=
sample
.
quantity
;
// NSDate *startDate = sample.startDate;
// NSDate *endDate = sample.endDate;
double
value
=
[
quantity
doubleValueForUnit
:
unit
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
@"value"
:
@
(
value
),
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
};
[
data
addObject
:
elem
];
}
completion
(
data
,
error
);
});
}
}];
[
self
.
healthStore
executeQuery
:
query
];
}
...
@@ -83,27 +143,6 @@
...
@@ -83,27 +143,6 @@
//- (void)fetchSumOfSamplesBetweenDatesForType:(HKQuantityType *)quantityType unit:(HKUnit *)unit startDate:(NSDate *)startDate endDate:(NSDate *)endDate completion:(void (^)(NSArray *, NSError *))completionHandler {
// NSPredicate *predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate];
//
// HKStatisticsQuery *query = [[HKStatisticsQuery alloc] initWithQuantityType:quantityType
// quantitySamplePredicate:predicate
// options:HKStatisticsOptionCumulativeSum
// completionHandler:^(HKStatisticsQuery *query, HKStatistics *result, NSError *error) {
// HKQuantity *sum = [result sumQuantity];
// if (completionHandler) {
// double value = [sum doubleValueForUnit:unit];
// completionHandler(value, error);
// }
// }];
//
// [self.healthStore executeQuery:query];
//}
-
(
void
)
fetchCumulativeSumStatisticsCollection
:(
HKQuantityType
*
)
quantityType
-
(
void
)
fetchCumulativeSumStatisticsCollection
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
unit
:(
HKUnit
*
)
unit
startDate
:(
NSDate
*
)
startDate
startDate
:(
NSDate
*
)
startDate
...
@@ -119,30 +158,21 @@
...
@@ -119,30 +158,21 @@
fromDate:
[
NSDate
date
]];
fromDate:
[
NSDate
date
]];
anchorComponents
.
hour
=
0
;
anchorComponents
.
hour
=
0
;
NSDate
*
anchorDate
=
[
calendar
dateFromComponents
:
anchorComponents
];
NSDate
*
anchorDate
=
[
calendar
dateFromComponents
:
anchorComponents
];
// HKQuantityType *quantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
// Create the query
// Create the query
HKStatisticsCollectionQuery
*
query
=
[[
HKStatisticsCollectionQuery
alloc
]
initWithQuantityType
:
quantityType
HKStatisticsCollectionQuery
*
query
=
[[
HKStatisticsCollectionQuery
alloc
]
initWithQuantityType
:
quantityType
quantitySamplePredicate:
nil
quantitySamplePredicate:
nil
options:
HKStatisticsOptionCumulativeSum
options:
HKStatisticsOptionCumulativeSum
anchorDate:
anchorDate
anchorDate:
anchorDate
intervalComponents:
interval
];
intervalComponents:
interval
];
// Set the results handler
// Set the results handler
query
.
initialResultsHandler
=
^
(
HKStatisticsCollectionQuery
*
query
,
HKStatisticsCollection
*
results
,
NSError
*
error
)
{
query
.
initialResultsHandler
=
^
(
HKStatisticsCollectionQuery
*
query
,
HKStatisticsCollection
*
results
,
NSError
*
error
)
{
if
(
error
)
{
if
(
error
)
{
// Perform proper error handling here
// Perform proper error handling here
NSLog
(
@"*** An error occurred while calculating the statistics: %@ ***"
,
error
.
localizedDescription
);
NSLog
(
@"*** An error occurred while calculating the statistics: %@ ***"
,
error
.
localizedDescription
);
}
}
// NSDate *endDate = [NSDate date];
// NSDate *startDate = [calendar dateByAddingUnit:NSCalendarUnitDay
// value:-7
// toDate:endDate
// options:0];
// Plot the daily step counts over the past 7 days
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
[
results
enumerateStatisticsFromDate
:
startDate
[
results
enumerateStatisticsFromDate
:
startDate
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
View file @
d5f10e70
...
@@ -24,4 +24,11 @@
...
@@ -24,4 +24,11 @@
+
(
NSDate
*
)
endDateFromOptionsDefaultNow
:(
NSDictionary
*
)
options
;
+
(
NSDate
*
)
endDateFromOptionsDefaultNow
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
HKUnit
*
)
defaultValue
;
+
(
NSUInteger
)
uintFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSUInteger
)
defaultValue
;
+
(
double
)
doubleFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
double
)
defaultValue
;
+
(
NSDate
*
)
dateFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSDate
*
)
defaultValue
;
+
(
NSString
*
)
stringFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSString
*
)
defaultValue
;
+
(
bool
)
boolFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
bool
)
defaultValue
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
d5f10e70
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
+
(
double
)
doubleValueFromOptions
:(
NSDictionary
*
)
options
{
+
(
double
)
doubleValueFromOptions
:(
NSDictionary
*
)
options
{
double
value
=
[[
options
objectForKey
:
@"value"
]
doubleValue
];
double
value
=
[[
options
objectForKey
:
@"value"
]
doubleValue
];
return
value
;
return
value
;
...
@@ -174,6 +175,107 @@
...
@@ -174,6 +175,107 @@
}
}
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
HKUnit
*
)
defaultValue
{
NSString
*
unitString
=
[
options
objectForKey
:
key
];
HKUnit
*
theUnit
;
if
([
unitString
isEqualToString
:
@"gram"
]){
theUnit
=
[
HKUnit
gramUnit
];
}
if
([
unitString
isEqualToString
:
@"pound"
]){
theUnit
=
[
HKUnit
poundUnit
];
}
if
([
unitString
isEqualToString
:
@"meter"
]){
theUnit
=
[
HKUnit
meterUnit
];
}
if
([
unitString
isEqualToString
:
@"inch"
]){
theUnit
=
[
HKUnit
inchUnit
];
}
if
([
unitString
isEqualToString
:
@"foot"
]){
theUnit
=
[
HKUnit
footUnit
];
}
if
([
unitString
isEqualToString
:
@"second"
]){
theUnit
=
[
HKUnit
secondUnit
];
}
if
([
unitString
isEqualToString
:
@"minute"
]){
theUnit
=
[
HKUnit
minuteUnit
];
}
if
([
unitString
isEqualToString
:
@"hour"
]){
theUnit
=
[
HKUnit
hourUnit
];
}
if
([
unitString
isEqualToString
:
@"day"
]){
theUnit
=
[
HKUnit
dayUnit
];
}
if
([
unitString
isEqualToString
:
@"joule"
]){
theUnit
=
[
HKUnit
jouleUnit
];
}
if
([
unitString
isEqualToString
:
@"calorie"
]){
theUnit
=
[
HKUnit
calorieUnit
];
}
if
([
unitString
isEqualToString
:
@"count"
]){
theUnit
=
[
HKUnit
countUnit
];
}
if
([
unitString
isEqualToString
:
@"percent"
]){
theUnit
=
[
HKUnit
percentUnit
];
}
if
(
theUnit
==
nil
){
theUnit
=
defaultValue
;
}
return
theUnit
;
}
+
(
NSUInteger
)
uintFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSUInteger
)
defaultValue
{
NSUInteger
val
;
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
!=
nil
){
val
=
[
num
unsignedIntValue
];
}
else
{
val
=
defaultValue
;
}
return
val
;
}
+
(
double
)
doubleFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
double
)
defaultValue
{
double
val
;
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
!=
nil
){
val
=
[
num
doubleValue
];
}
else
{
val
=
defaultValue
;
}
return
val
;
}
+
(
NSDate
*
)
dateFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSDate
*
)
defaultValue
{
NSString
*
dateString
=
[
options
objectForKey
:
key
];
NSDate
*
date
;
if
(
dateString
!=
nil
){
date
=
[
RCTAppleHealthKit
parseISO8601DateFromString
:
dateString
];
}
else
{
date
=
defaultValue
;
}
return
date
;
}
+
(
NSString
*
)
stringFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSString
*
)
defaultValue
{
NSString
*
str
=
[
options
objectForKey
:
key
];
if
(
str
==
nil
){
str
=
defaultValue
;
}
return
str
;
}
+
(
bool
)
boolFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
bool
)
defaultValue
{
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
==
nil
){
return
defaultValue
;
}
return
[
num
boolValue
];
}
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
d5f10e70
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#import "RCTAppleHealthKit+Methods_Body.h"
#import "RCTAppleHealthKit+Methods_Body.h"
#import "RCTAppleHealthKit+Methods_Fitness.h"
#import "RCTAppleHealthKit+Methods_Fitness.h"
#import "RCTAppleHealthKit+Methods_Characteristic.h"
@implementation
RCTAppleHealthKit
@implementation
RCTAppleHealthKit
...
@@ -29,11 +30,26 @@ RCT_EXPORT_METHOD(initHealthKit:(NSDictionary *)input callback:(RCTResponseSende
...
@@ -29,11 +30,26 @@ RCT_EXPORT_METHOD(initHealthKit:(NSDictionary *)input callback:(RCTResponseSende
[
self
initializeHealthKit
:
input
callback
:
callback
];
[
self
initializeHealthKit
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getBiologicalSex
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
characteristic_getBiologicalSex
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getDateOfBirth
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
characteristic_getDateOfBirth
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getLatestWeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getLatestWeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
body_getCurrentWeight
:
input
callback
:
callback
];
[
self
body_getCurrentWeight
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getWeightSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
body_getWeightSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
saveWeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
saveWeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
body_saveWeight
:
input
callback
:
callback
];
[
self
body_saveWeight
:
input
callback
:
callback
];
...
@@ -45,6 +61,11 @@ RCT_EXPORT_METHOD(getLatestHeight:(NSDictionary *)input callback:(RCTResponseSen
...
@@ -45,6 +61,11 @@ RCT_EXPORT_METHOD(getLatestHeight:(NSDictionary *)input callback:(RCTResponseSen
[
self
body_getMostRecentHeight
:
input
callback
:
callback
];
[
self
body_getMostRecentHeight
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getHeightSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
body_getHeightSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
saveHeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
saveHeight
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
body_saveHeight
:
input
callback
:
callback
];
[
self
body_saveHeight
:
input
callback
:
callback
];
...
...
examples/BodyMeasurements/app/stores/body.js
View file @
d5f10e70
...
@@ -45,8 +45,12 @@ class BodyStore extends airflux.Store {
...
@@ -45,8 +45,12 @@ class BodyStore extends airflux.Store {
//this.listenTo(actions.addWeight, this._onactn_addWeight)
//this.listenTo(actions.addWeight, this._onactn_addWeight)
this
.
_initHealthKit
=
this
.
_initHealthKit
.
bind
(
this
);
this
.
_initHealthKit
=
this
.
_initHealthKit
.
bind
(
this
);
this
.
_fetchHealthKitUserBiologicalSex
=
this
.
_fetchHealthKitUserBiologicalSex
.
bind
(
this
);
this
.
_fetchHealthKitUserDateOfBirth
=
this
.
_fetchHealthKitUserDateOfBirth
.
bind
(
this
);
this
.
_fetchHealthKitUserWeight
=
this
.
_fetchHealthKitUserWeight
.
bind
(
this
);
this
.
_fetchHealthKitUserWeight
=
this
.
_fetchHealthKitUserWeight
.
bind
(
this
);
this
.
_fetchHealthKitUserWeightSamples
=
this
.
_fetchHealthKitUserWeightSamples
.
bind
(
this
);
this
.
_fetchHealthKitUserHeight
=
this
.
_fetchHealthKitUserHeight
.
bind
(
this
);
this
.
_fetchHealthKitUserHeight
=
this
.
_fetchHealthKitUserHeight
.
bind
(
this
);
this
.
_fetchHealthKitUserHeightSamples
=
this
.
_fetchHealthKitUserHeightSamples
.
bind
(
this
);
this
.
_fetchHealthKitUserBmi
=
this
.
_fetchHealthKitUserBmi
.
bind
(
this
);
this
.
_fetchHealthKitUserBmi
=
this
.
_fetchHealthKitUserBmi
.
bind
(
this
);
this
.
_fetchHealthKitStepCountToday
=
this
.
_fetchHealthKitStepCountToday
.
bind
(
this
);
this
.
_fetchHealthKitStepCountToday
=
this
.
_fetchHealthKitStepCountToday
.
bind
(
this
);
this
.
_fetchHealthKitStepCountForDay
=
this
.
_fetchHealthKitStepCountForDay
.
bind
(
this
);
this
.
_fetchHealthKitStepCountForDay
=
this
.
_fetchHealthKitStepCountForDay
.
bind
(
this
);
...
@@ -91,7 +95,7 @@ class BodyStore extends airflux.Store {
...
@@ -91,7 +95,7 @@ class BodyStore extends airflux.Store {
let
healthKitOptions
=
{
let
healthKitOptions
=
{
permissions
:
{
permissions
:
{
read
:
[
"
Height
"
,
"
Weight
"
,
"
Steps
"
,
"
DateOfBirth
"
,
"
BodyMassIndex
"
,
"
LeanBodyMass
"
,
"
BodyFatPercentage
"
],
read
:
[
"
Height
"
,
"
Weight
"
,
"
Steps
"
,
"
DateOfBirth
"
,
"
BodyMassIndex
"
,
"
LeanBodyMass
"
,
"
BodyFatPercentage
"
,
"
BiologicalSex
"
],
write
:
[
"
Weight
"
,
"
Height
"
,
"
BodyMassIndex
"
]
write
:
[
"
Weight
"
,
"
Height
"
,
"
BodyMassIndex
"
]
}
}
};
};
...
@@ -112,6 +116,12 @@ class BodyStore extends airflux.Store {
...
@@ -112,6 +116,12 @@ class BodyStore extends airflux.Store {
self
.
_fetchHealthKitStepCountForDay
();
self
.
_fetchHealthKitStepCountForDay
();
self
.
_fetchDailyStepCounts
();
self
.
_fetchDailyStepCounts
();
self
.
_fetchHealthKitUserWeightSamples
();
self
.
_fetchHealthKitUserHeightSamples
();
self
.
_fetchHealthKitUserBiologicalSex
();
self
.
_fetchHealthKitUserDateOfBirth
();
//setTimeout(() => {self._saveBmi(27)}, 1000);
//setTimeout(() => {self._saveBmi(27)}, 1000);
//setTimeout(() => {self._onactn_addWeight({
//setTimeout(() => {self._onactn_addWeight({
// weight: 215,
// weight: 215,
...
@@ -155,6 +165,28 @@ class BodyStore extends airflux.Store {
...
@@ -155,6 +165,28 @@ class BodyStore extends airflux.Store {
}
}
_fetchHealthKitUserBiologicalSex
()
{
let
self
=
this
;
AppleHealthKit
.
getBiologicalSex
(
null
,
(
err
,
sex
)
=>
{
if
(
this
.
_handleHealthKitError
(
err
,
'
getBiologicalSex
'
)){
return
;
}
console
.
log
(
'
BiologicalSex:
'
,
sex
);
});
}
_fetchHealthKitUserDateOfBirth
()
{
let
self
=
this
;
AppleHealthKit
.
getDateOfBirth
(
null
,
(
err
,
dob
)
=>
{
if
(
this
.
_handleHealthKitError
(
err
,
'
getDateOfBirth
'
)){
return
;
}
console
.
log
(
'
DateOfBirth:
'
,
dob
);
});
}
_saveHeight
(
height_inches
)
{
_saveHeight
(
height_inches
)
{
let
self
=
this
;
let
self
=
this
;
let
options
=
{
let
options
=
{
...
@@ -197,6 +229,25 @@ class BodyStore extends airflux.Store {
...
@@ -197,6 +229,25 @@ class BodyStore extends airflux.Store {
}
}
_fetchHealthKitUserWeightSamples
()
{
let
self
=
this
;
let
d
=
new
Date
(
2016
,
4
,
27
);
let
options
=
{
unit
:
"
pound
"
,
startDate
:
d
.
toISOString
(),
ascending
:
false
,
limit
:
2
,
};
AppleHealthKit
.
getWeightSamples
(
options
,
(
err
,
samples
)
=>
{
if
(
this
.
_handleHealthKitError
(
err
,
'
getWeightSamples
'
)){
return
;
}
console
.
log
(
'
weight samples:
'
,
samples
);
});
}
_fetchHealthKitUserHeight
()
{
_fetchHealthKitUserHeight
()
{
let
self
=
this
;
let
self
=
this
;
let
options
=
{
let
options
=
{
...
@@ -220,6 +271,25 @@ class BodyStore extends airflux.Store {
...
@@ -220,6 +271,25 @@ class BodyStore extends airflux.Store {
}
}
_fetchHealthKitUserHeightSamples
()
{
let
self
=
this
;
let
d
=
new
Date
(
2016
,
1
,
1
);
let
options
=
{
unit
:
"
inch
"
,
startDate
:
d
.
toISOString
(),
//ascending: false,
//limit:2,
};
AppleHealthKit
.
getHeightSamples
(
options
,
(
err
,
samples
)
=>
{
if
(
this
.
_handleHealthKitError
(
err
,
'
getHeightSamples
'
)){
return
;
}
console
.
log
(
'
height samples:
'
,
samples
);
});
}
_fetchHealthKitUserBmi
()
{
_fetchHealthKitUserBmi
()
{
let
self
=
this
;
let
self
=
this
;
AppleHealthKit
.
getLatestBmi
({
blah
:
true
},
(
err
,
bmi
)
=>
{
AppleHealthKit
.
getLatestBmi
({
blah
:
true
},
(
err
,
bmi
)
=>
{
...
@@ -359,7 +429,7 @@ class BodyStore extends airflux.Store {
...
@@ -359,7 +429,7 @@ class BodyStore extends airflux.Store {
GetHeightFormatted
()
{
GetHeightFormatted
()
{
let
feet
=
_
.
floor
((
DATA
.
height
/
12
));
let
feet
=
_
.
floor
((
DATA
.
height
/
12
));
let
inches
=
DATA
.
height
%
12
;
let
inches
=
_
.
floor
((
DATA
.
height
%
12
))
;
let
formatted
=
''
+
feet
+
'
\'
'
+
inches
+
'
"
'
;
let
formatted
=
''
+
feet
+
'
\'
'
+
inches
+
'
"
'
;
return
formatted
;
return
formatted
;
}
}
...
...
examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj
View file @
d5f10e70
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
13B07FC11A68108700A75B9A
/* main.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
13B07FB71A68108700A75B9A
/* main.m */
;
};
13B07FC11A68108700A75B9A
/* main.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
13B07FB71A68108700A75B9A
/* main.m */
;
};
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
37
87538F1D23661D0016D000
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3787538E1D2366190016D000
/* libRCTAppleHealthKit.a */
;
};
37
7D44FA1D248091004E35CB
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
377D44F91D24808D004E35CB
/* libRCTAppleHealthKit.a */
;
};
37E9B8741D21B52F0090B19B
/* HealthKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
37E9B8731D21B52F0090B19B
/* HealthKit.framework */
;
};
37E9B8741D21B52F0090B19B
/* HealthKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
37E9B8731D21B52F0090B19B
/* HealthKit.framework */
;
};
832341BD1AAA6AB300B99B32
/* libRCTText.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
832341B51AAA6A8300B99B32
/* libRCTText.a */
;
};
832341BD1AAA6AB300B99B32
/* libRCTText.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
832341B51AAA6A8300B99B32
/* libRCTText.a */
;
};
/* End PBXBuildFile section */
/* End PBXBuildFile section */
...
@@ -91,9 +91,9 @@
...
@@ -91,9 +91,9 @@
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteInfo
=
React
;
remoteInfo
=
React
;
};
};
37
87538D1D2366190016D000
/* PBXContainerItemProxy */
=
{
37
7D44F81D24808D004E35CB
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
isa
=
PBXContainerItemProxy
;
containerPortal
=
37
8753891D2366190016D000
/* RCTAppleHealthKit.xcodeproj */
;
containerPortal
=
37
7D44F41D24808D004E35CB
/* RCTAppleHealthKit.xcodeproj */
;
proxyType
=
2
;
proxyType
=
2
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteInfo
=
RCTAppleHealthKit
;
remoteInfo
=
RCTAppleHealthKit
;
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
13B07FB61A68108700A75B9A
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
Info.plist
;
path
=
BodyMeasurements/Info.plist
;
sourceTree
=
"<group>"
;
};
13B07FB61A68108700A75B9A
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
Info.plist
;
path
=
BodyMeasurements/Info.plist
;
sourceTree
=
"<group>"
;
};
13B07FB71A68108700A75B9A
/* main.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
main.m
;
path
=
BodyMeasurements/main.m
;
sourceTree
=
"<group>"
;
};
13B07FB71A68108700A75B9A
/* main.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
main.m
;
path
=
BodyMeasurements/main.m
;
sourceTree
=
"<group>"
;
};
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37
8753891D2366190016D000
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37
7D44F41D24808D004E35CB
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37E9B8731D21B52F0090B19B
/* HealthKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
HealthKit.framework
;
path
=
System/Library/Frameworks/HealthKit.framework
;
sourceTree
=
SDKROOT
;
};
37E9B8731D21B52F0090B19B
/* HealthKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
HealthKit.framework
;
path
=
System/Library/Frameworks/HealthKit.framework
;
sourceTree
=
SDKROOT
;
};
37E9B8751D21B52F0090B19B
/* BodyMeasurements.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xml
;
name
=
BodyMeasurements.entitlements
;
path
=
BodyMeasurements/BodyMeasurements.entitlements
;
sourceTree
=
"<group>"
;
};
37E9B8751D21B52F0090B19B
/* BodyMeasurements.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xml
;
name
=
BodyMeasurements.entitlements
;
path
=
BodyMeasurements/BodyMeasurements.entitlements
;
sourceTree
=
"<group>"
;
};
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTLinking.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"
;
sourceTree
=
"<group>"
;
};
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTLinking.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"
;
sourceTree
=
"<group>"
;
};
...
@@ -154,7 +154,7 @@
...
@@ -154,7 +154,7 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
37
87538F1D23661D0016D000
/* libRCTAppleHealthKit.a in Frameworks */
,
37
7D44FA1D248091004E35CB
/* libRCTAppleHealthKit.a in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
37E9B8741D21B52F0090B19B
/* HealthKit.framework in Frameworks */
,
37E9B8741D21B52F0090B19B
/* HealthKit.framework in Frameworks */
,
...
@@ -268,10 +268,10 @@
...
@@ -268,10 +268,10 @@
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
37
87538A1D2366190016D000
/* Products */
=
{
37
7D44F51D24808D004E35CB
/* Products */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
37
87538E1D2366190016D000
/* libRCTAppleHealthKit.a */
,
37
7D44F91D24808D004E35CB
/* libRCTAppleHealthKit.a */
,
);
);
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -287,7 +287,7 @@
...
@@ -287,7 +287,7 @@
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
37
8753891D2366190016D000
/* RCTAppleHealthKit.xcodeproj */
,
37
7D44F41D24808D004E35CB
/* RCTAppleHealthKit.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
...
@@ -411,8 +411,8 @@
...
@@ -411,8 +411,8 @@
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
},
},
{
{
ProductGroup
=
37
87538A1D2366190016D000
/* Products */
;
ProductGroup
=
37
7D44F51D24808D004E35CB
/* Products */
;
ProjectRef
=
37
8753891D2366190016D000
/* RCTAppleHealthKit.xcodeproj */
;
ProjectRef
=
37
7D44F41D24808D004E35CB
/* RCTAppleHealthKit.xcodeproj */
;
},
},
{
{
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
...
@@ -516,11 +516,11 @@
...
@@ -516,11 +516,11 @@
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
};
37
87538E1D2366190016D000
/* libRCTAppleHealthKit.a */
=
{
37
7D44F91D24808D004E35CB
/* libRCTAppleHealthKit.a */
=
{
isa
=
PBXReferenceProxy
;
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
fileType
=
archive.ar
;
path
=
libRCTAppleHealthKit.a
;
path
=
libRCTAppleHealthKit.a
;
remoteRef
=
37
87538D1D2366190016D000
/* PBXContainerItemProxy */
;
remoteRef
=
37
7D44F81D24808D004E35CB
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
};
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment