Commit d8862d97 authored by Greg Wilson's avatar Greg Wilson

added saveHeight functionality to example app body store and created actions

parent cb3ce9cc
/**
* Created by greg on 2016-06-28.
*/
var airflux = require('airflux');
let actions = {
saveWeight: new airflux.Action().asFunction,
saveHeight: new airflux.Action().asFunction,
};
module.exports = actions;
export default actions;
...@@ -51,6 +51,8 @@ class BodyStore extends airflux.Store { ...@@ -51,6 +51,8 @@ class BodyStore extends airflux.Store {
this._fetchHealthKitStepCountToday = this._fetchHealthKitStepCountToday.bind(this); this._fetchHealthKitStepCountToday = this._fetchHealthKitStepCountToday.bind(this);
this._fetchHealthKitBodyFatPercentage = this._fetchHealthKitBodyFatPercentage.bind(this); this._fetchHealthKitBodyFatPercentage = this._fetchHealthKitBodyFatPercentage.bind(this);
this._fetchHealthKitLeanBodyMass = this._fetchHealthKitLeanBodyMass.bind(this); this._fetchHealthKitLeanBodyMass = this._fetchHealthKitLeanBodyMass.bind(this);
this._saveHeight = this._saveHeight.bind(this);
this.GetWeightValue = this.GetWeightValue.bind(this); this.GetWeightValue = this.GetWeightValue.bind(this);
this.GetWeightFormatted = this.GetWeightFormatted.bind(this); this.GetWeightFormatted = this.GetWeightFormatted.bind(this);
this.GetSteps = this.GetSteps.bind(this); this.GetSteps = this.GetSteps.bind(this);
...@@ -87,7 +89,7 @@ class BodyStore extends airflux.Store { ...@@ -87,7 +89,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"],
write: ["Weight"] write: ["Weight", "Height"]
} }
}; };
...@@ -141,6 +143,27 @@ class BodyStore extends airflux.Store { ...@@ -141,6 +143,27 @@ class BodyStore extends airflux.Store {
} }
_saveHeight(height_inches) {
let self = this;
let options = {
value: height_inches
};
AppleHealthKit.saveHeight(options, (err, res) => {
if(this._handleHealthKitError(err, 'saveHeight')){
return;
}
console.log('Height Saved Successfully...');
DATA.height = height_inches;
self.trigger({
name: 'change:height',
target: null,
data: DATA.height
});
});
}
_fetchHealthKitUserWeight() { _fetchHealthKitUserWeight() {
let self = this; let self = this;
AppleHealthKit.getLatestWeight(null, (err, weight) => { AppleHealthKit.getLatestWeight(null, (err, weight) => {
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
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 */; };
378753571D23261E0016D000 /* libRCTAppleHealthKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 378753561D23261A0016D000 /* libRCTAppleHealthKit.a */; };
37E9B8741D21B52F0090B19B /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E9B8731D21B52F0090B19B /* HealthKit.framework */; }; 37E9B8741D21B52F0090B19B /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E9B8731D21B52F0090B19B /* HealthKit.framework */; };
37E9B89D1D21C63C0090B19B /* libRCTAppleHealthKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E9B89C1D21C6380090B19B /* libRCTAppleHealthKit.a */; };
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;
}; };
37E9B89B1D21C6380090B19B /* PBXContainerItemProxy */ = { 378753551D23261A0016D000 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = 37E9B8971D21C6380090B19B /* RCTAppleHealthKit.xcodeproj */; containerPortal = 378753511D23261A0016D000 /* RCTAppleHealthKit.xcodeproj */;
proxyType = 2; proxyType = 2;
remoteGlobalIDString = 3774C88D1D2092F20000B3F3; remoteGlobalIDString = 3774C88D1D2092F20000B3F3;
remoteInfo = RCTAppleHealthKit; remoteInfo = RCTAppleHealthKit;
...@@ -134,9 +134,9 @@ ...@@ -134,9 +134,9 @@
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>"; };
378753511D23261A0016D000 /* 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>"; };
37E9B8971D21C6380090B19B /* 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>"; }; 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>"; }; 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 */ /* End PBXFileReference section */
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
37E9B89D1D21C63C0090B19B /* libRCTAppleHealthKit.a in Frameworks */, 378753571D23261E0016D000 /* 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>";
}; };
37E9B8981D21C6380090B19B /* Products */ = { 378753521D23261A0016D000 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
37E9B89C1D21C6380090B19B /* libRCTAppleHealthKit.a */, 378753561D23261A0016D000 /* 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 = (
37E9B8971D21C6380090B19B /* RCTAppleHealthKit.xcodeproj */, 378753511D23261A0016D000 /* 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 = 37E9B8981D21C6380090B19B /* Products */; ProductGroup = 378753521D23261A0016D000 /* Products */;
ProjectRef = 37E9B8971D21C6380090B19B /* RCTAppleHealthKit.xcodeproj */; ProjectRef = 378753511D23261A0016D000 /* 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;
}; };
37E9B89C1D21C6380090B19B /* libRCTAppleHealthKit.a */ = { 378753561D23261A0016D000 /* libRCTAppleHealthKit.a */ = {
isa = PBXReferenceProxy; isa = PBXReferenceProxy;
fileType = archive.ar; fileType = archive.ar;
path = libRCTAppleHealthKit.a; path = libRCTAppleHealthKit.a;
remoteRef = 37E9B89B1D21C6380090B19B /* PBXContainerItemProxy */; remoteRef = 378753551D23261A0016D000 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR; sourceTree = BUILT_PRODUCTS_DIR;
}; };
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment