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
e43cdf93
Commit
e43cdf93
authored
Jul 02, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added fitness_saveSteps method and exported RCT method saveSteps
parent
d9b4e01d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
13 deletions
+78
-13
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
+2
-1
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
+42
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+5
-0
examples/StepsDemo/app/components/home/index.js
examples/StepsDemo/app/components/home/index.js
+17
-0
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
+12
-12
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
View file @
e43cdf93
...
...
@@ -14,9 +14,10 @@
-
(
void
)
fitness_getStepCountForDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDailyStepCounts
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDailyStepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_saveSteps
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDistanceWalkingRunningOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDistanceCyclingOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getFlightsClimbedOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
View file @
e43cdf93
...
...
@@ -104,6 +104,48 @@
}
-
(
void
)
fitness_saveSteps
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
// double height = [RCTAppleHealthKit doubleValueFromOptions:input];
double
value
=
[
RCTAppleHealthKit
doubleFromOptions
:
input
key
:
@"value"
withDefault
:
(
double
)
0
];
NSDate
*
startDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
nil
];
NSDate
*
endDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"endDate"
withDefault
:
[
NSDate
date
]];
HKUnit
*
unit
=
[
HKUnit
countUnit
];
// NSDate *sampleDate = [RCTAppleHealthKit dateFromOptionsDefaultNow:input];
// HKUnit *heightUnit = [RCTAppleHealthKit hkUnitFromOptions:input];
// if(heightUnit == nil){
// heightUnit = [HKUnit inchUnit];
// }
if
(
startDate
==
nil
||
endDate
==
nil
){
callback
(@[
RCTMakeError
(
@"startDate and endDate are required in options"
,
nil
,
nil
)]);
return
;
}
HKQuantity
*
quantity
=
[
HKQuantity
quantityWithUnit
:
unit
doubleValue
:
value
];
HKQuantityType
*
type
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
HKQuantitySample
*
sample
=
[
HKQuantitySample
quantitySampleWithType
:
type
quantity
:
quantity
startDate
:
startDate
endDate
:
endDate
];
[
self
.
healthStore
saveObject
:
sample
withCompletion
:
^
(
BOOL
success
,
NSError
*
error
)
{
if
(
!
success
)
{
NSLog
(
@"An error occured saving the step count sample %@. The error was: %@."
,
sample
,
error
);
callback
(@[
RCTMakeError
(
@"An error occured saving the step count sample"
,
error
,
nil
)]);
return
;
}
callback
(@[[
NSNull
null
],
@
(
value
)]);
}];
}
-
(
void
)
fitness_getDistanceWalkingRunningOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
meterUnit
]];
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
e43cdf93
...
...
@@ -114,6 +114,11 @@ RCT_EXPORT_METHOD(getDailyStepSamples:(NSDictionary *)input callback:(RCTRespons
[
self
fitness_getDailyStepSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
saveSteps
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
fitness_saveSteps
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getDistanceWalkingRunning
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
fitness_getDistanceWalkingRunningOnDay
:
input
callback
:
callback
];
...
...
examples/StepsDemo/app/components/home/index.js
View file @
e43cdf93
...
...
@@ -59,6 +59,23 @@ class Home extends Component {
}
this
.
_fetchStepsToday
();
this
.
_fetchStepsHistory
();
//setTimeout(() => {
//
// let options = {
// value: 350,
// startDate: (new Date(2016,6,2,6,0,0)).toISOString(),
// endDate: (new Date(2016,6,2,6,30,0)).toISOString()
// };
// AppleHealthKit.saveSteps(options, (err, res) => {
// if(this._handleHKError(err, 'saveSteps')){
// return;
// }
// console.log('steps saved...');
// });
//
//},1000);
});
}
});
...
...
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
View file @
e43cdf93
...
...
@@ -23,7 +23,7 @@
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
378616B61D257B040027C300
/* HealthKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
378616B51D257B040027C300
/* HealthKit.framework */
;
};
37
87CCB71D25F1D60080733E
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3787CCB61D25F1D30080733E
/* libRCTAppleHealthKit.a */
;
};
37
9EEE921D285CA70062AF55
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
379EEE911D285CA30062AF55
/* libRCTAppleHealthKit.a */
;
};
832341BD1AAA6AB300B99B32
/* libRCTText.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
832341B51AAA6A8300B99B32
/* libRCTText.a */
;
};
/* End PBXBuildFile section */
...
...
@@ -91,9 +91,9 @@
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteInfo
=
React
;
};
37
87CCB51D25F1D30080733E
/* PBXContainerItemProxy */
=
{
37
9EEE901D285CA30062AF55
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
37
87CCB11D25F1D30080733E
/* RCTAppleHealthKit.xcodeproj */
;
containerPortal
=
37
9EEE8C1D285CA20062AF55
/* RCTAppleHealthKit.xcodeproj */
;
proxyType
=
2
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteInfo
=
RCTAppleHealthKit
;
...
...
@@ -136,7 +136,7 @@
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
378616B51D257B040027C300
/* HealthKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
HealthKit.framework
;
path
=
System/Library/Frameworks/HealthKit.framework
;
sourceTree
=
SDKROOT
;
};
378616B71D257B040027C300
/* StepsDemo.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xml
;
name
=
StepsDemo.entitlements
;
path
=
StepsDemo/StepsDemo.entitlements
;
sourceTree
=
"<group>"
;
};
37
87CCB11D25F1D30080733E
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37
9EEE8C1D285CA20062AF55
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.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>"
;
};
832341B01AAA6A8300B99B32
/* RCTText.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTText.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -154,7 +154,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
37
87CCB71D25F1D60080733E
/* libRCTAppleHealthKit.a in Frameworks */
,
37
9EEE921D285CA70062AF55
/* libRCTAppleHealthKit.a in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
378616B61D257B040027C300
/* HealthKit.framework in Frameworks */
,
...
...
@@ -268,10 +268,10 @@
name
=
Products
;
sourceTree
=
"<group>"
;
};
37
87CCB21D25F1D30080733E
/* Products */
=
{
37
9EEE8D1D285CA20062AF55
/* Products */
=
{
isa
=
PBXGroup
;
children
=
(
37
87CCB61D25F1D30080733E
/* libRCTAppleHealthKit.a */
,
37
9EEE911D285CA30062AF55
/* libRCTAppleHealthKit.a */
,
);
name
=
Products
;
sourceTree
=
"<group>"
;
...
...
@@ -287,7 +287,7 @@
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
isa
=
PBXGroup
;
children
=
(
37
87CCB11D25F1D30080733E
/* RCTAppleHealthKit.xcodeproj */
,
37
9EEE8C1D285CA20062AF55
/* RCTAppleHealthKit.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
...
...
@@ -411,8 +411,8 @@
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
},
{
ProductGroup
=
37
87CCB21D25F1D30080733E
/* Products */
;
ProjectRef
=
37
87CCB11D25F1D30080733E
/* RCTAppleHealthKit.xcodeproj */
;
ProductGroup
=
37
9EEE8D1D285CA20062AF55
/* Products */
;
ProjectRef
=
37
9EEE8C1D285CA20062AF55
/* RCTAppleHealthKit.xcodeproj */
;
},
{
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
...
...
@@ -516,11 +516,11 @@
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
37
87CCB61D25F1D30080733E
/* libRCTAppleHealthKit.a */
=
{
37
9EEE911D285CA30062AF55
/* libRCTAppleHealthKit.a */
=
{
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
path
=
libRCTAppleHealthKit.a
;
remoteRef
=
37
87CCB51D25F1D30080733E
/* PBXContainerItemProxy */
;
remoteRef
=
37
9EEE901D285CA30062AF55
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
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