diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index 073f1be72c5026f28934346cdf5f86843470fcd2..b0dedf21a65c18cfa2fe7e082ec19d30aefe0cf6 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 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 */; }; 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 */ /* Begin PBXCopyFilesBuildPhase section */ @@ -43,6 +44,8 @@ 3774C8D31D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Body.m"; sourceTree = ""; }; 3774C8D51D20C65F0000B3F3 /* RCTAppleHealthKit+Methods_Fitness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Fitness.h"; sourceTree = ""; }; 3774C8D61D20C65F0000B3F3 /* RCTAppleHealthKit+Methods_Fitness.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Fitness.m"; sourceTree = ""; }; + 377D44F11D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Characteristic.h"; sourceTree = ""; }; + 377D44F21D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Characteristic.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -87,6 +90,8 @@ 3774C8D31D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m */, 3774C8D51D20C65F0000B3F3 /* RCTAppleHealthKit+Methods_Fitness.h */, 3774C8D61D20C65F0000B3F3 /* RCTAppleHealthKit+Methods_Fitness.m */, + 377D44F11D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.h */, + 377D44F21D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.m */, ); path = RCTAppleHealthKit; sourceTree = ""; @@ -151,6 +156,7 @@ 3774C8A11D20A6B90000B3F3 /* RCTAppleHealthKit+Utils.m in Sources */, 3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */, 3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */, + 377D44F31D247D0A004E35CB /* RCTAppleHealthKit+Methods_Characteristic.m in Sources */, 3774C89E1D2095850000B3F3 /* RCTAppleHealthKit+TypesAndPermissions.m in Sources */, 3774C8D71D20C65F0000B3F3 /* RCTAppleHealthKit+Methods_Fitness.m in Sources */, ); @@ -286,6 +292,7 @@ 3774C8981D2092F20000B3F3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/examples/BodyMeasurements/app/stores/body.js b/examples/BodyMeasurements/app/stores/body.js index c69028d223452dc1cbfb3351b2a15dca8afba4db..7ffab822838df999a34e9d45261cd4acafd0a3fe 100644 --- a/examples/BodyMeasurements/app/stores/body.js +++ b/examples/BodyMeasurements/app/stores/body.js @@ -45,8 +45,12 @@ class BodyStore extends airflux.Store { //this.listenTo(actions.addWeight, this._onactn_addWeight) 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._fetchHealthKitUserWeightSamples = this._fetchHealthKitUserWeightSamples.bind(this); this._fetchHealthKitUserHeight = this._fetchHealthKitUserHeight.bind(this); + this._fetchHealthKitUserHeightSamples = this._fetchHealthKitUserHeightSamples.bind(this); this._fetchHealthKitUserBmi = this._fetchHealthKitUserBmi.bind(this); this._fetchHealthKitStepCountToday = this._fetchHealthKitStepCountToday.bind(this); this._fetchHealthKitStepCountForDay = this._fetchHealthKitStepCountForDay.bind(this); @@ -91,7 +95,7 @@ class BodyStore extends airflux.Store { let healthKitOptions = { permissions: { - read: ["Height", "Weight", "Steps", "DateOfBirth", "BodyMassIndex", "LeanBodyMass", "BodyFatPercentage"], + read: ["Height", "Weight", "Steps", "DateOfBirth", "BodyMassIndex", "LeanBodyMass", "BodyFatPercentage", "BiologicalSex"], write: ["Weight", "Height", "BodyMassIndex"] } }; @@ -112,6 +116,12 @@ class BodyStore extends airflux.Store { self._fetchHealthKitStepCountForDay(); self._fetchDailyStepCounts(); + self._fetchHealthKitUserWeightSamples(); + self._fetchHealthKitUserHeightSamples(); + + self._fetchHealthKitUserBiologicalSex(); + self._fetchHealthKitUserDateOfBirth(); + //setTimeout(() => {self._saveBmi(27)}, 1000); //setTimeout(() => {self._onactn_addWeight({ // weight: 215, @@ -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) { let self = this; let options = { @@ -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() { let self = this; let options = { @@ -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() { let self = this; AppleHealthKit.getLatestBmi({blah:true}, (err, bmi) => { @@ -359,7 +429,7 @@ class BodyStore extends airflux.Store { GetHeightFormatted() { let feet = _.floor((DATA.height / 12)); - let inches = DATA.height % 12; + let inches = _.floor((DATA.height % 12)); let formatted = '' + feet + '\'' + inches + '"'; return formatted; } diff --git a/examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj b/examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj index 91857ab4230689e26614143d6a9bd4720a6e281d..b8174ab21aef2d7a7891cadf5fb5782dd1b7af3e 100644 --- a/examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj +++ b/examples/BodyMeasurements/ios/BodyMeasurements.xcodeproj/project.pbxproj @@ -22,7 +22,7 @@ 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 3787538F1D23661D0016D000 /* libRCTAppleHealthKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3787538E1D2366190016D000 /* libRCTAppleHealthKit.a */; }; + 377D44FA1D248091004E35CB /* libRCTAppleHealthKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 377D44F91D24808D004E35CB /* libRCTAppleHealthKit.a */; }; 37E9B8741D21B52F0090B19B /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E9B8731D21B52F0090B19B /* HealthKit.framework */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; /* End PBXBuildFile section */ @@ -91,9 +91,9 @@ remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; remoteInfo = React; }; - 3787538D1D2366190016D000 /* PBXContainerItemProxy */ = { + 377D44F81D24808D004E35CB /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 378753891D2366190016D000 /* RCTAppleHealthKit.xcodeproj */; + containerPortal = 377D44F41D24808D004E35CB /* RCTAppleHealthKit.xcodeproj */; proxyType = 2; remoteGlobalIDString = 3774C88D1D2092F20000B3F3; remoteInfo = RCTAppleHealthKit; @@ -134,7 +134,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BodyMeasurements/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = BodyMeasurements/main.m; sourceTree = ""; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; - 378753891D2366190016D000 /* RCTAppleHealthKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAppleHealthKit.xcodeproj; path = "../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"; sourceTree = ""; }; + 377D44F41D24808D004E35CB /* RCTAppleHealthKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAppleHealthKit.xcodeproj; path = "../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"; sourceTree = ""; }; 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 = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; @@ -154,7 +154,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3787538F1D23661D0016D000 /* libRCTAppleHealthKit.a in Frameworks */, + 377D44FA1D248091004E35CB /* libRCTAppleHealthKit.a in Frameworks */, 146834051AC3E58100842450 /* libReact.a in Frameworks */, 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 37E9B8741D21B52F0090B19B /* HealthKit.framework in Frameworks */, @@ -268,10 +268,10 @@ name = Products; sourceTree = ""; }; - 3787538A1D2366190016D000 /* Products */ = { + 377D44F51D24808D004E35CB /* Products */ = { isa = PBXGroup; children = ( - 3787538E1D2366190016D000 /* libRCTAppleHealthKit.a */, + 377D44F91D24808D004E35CB /* libRCTAppleHealthKit.a */, ); name = Products; sourceTree = ""; @@ -287,7 +287,7 @@ 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( - 378753891D2366190016D000 /* RCTAppleHealthKit.xcodeproj */, + 377D44F41D24808D004E35CB /* RCTAppleHealthKit.xcodeproj */, 146833FF1AC3E56700842450 /* React.xcodeproj */, 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, @@ -411,8 +411,8 @@ ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; }, { - ProductGroup = 3787538A1D2366190016D000 /* Products */; - ProjectRef = 378753891D2366190016D000 /* RCTAppleHealthKit.xcodeproj */; + ProductGroup = 377D44F51D24808D004E35CB /* Products */; + ProjectRef = 377D44F41D24808D004E35CB /* RCTAppleHealthKit.xcodeproj */; }, { ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; @@ -516,11 +516,11 @@ remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 3787538E1D2366190016D000 /* libRCTAppleHealthKit.a */ = { + 377D44F91D24808D004E35CB /* libRCTAppleHealthKit.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = libRCTAppleHealthKit.a; - remoteRef = 3787538D1D2366190016D000 /* PBXContainerItemProxy */; + remoteRef = 377D44F81D24808D004E35CB /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {