### Example Output for Daily Flights Climbed Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDailyFlightsClimbedSamples.md An example of the data structure returned for daily flights climbed samples, including start and end dates and the count of flights climbed. ```json [ { "endDate": "2021-03-22T17:00:00.000-0300", "startDate": "2021-03-22T16:00:00.000-0300", "value": 5 } ] ``` -------------------------------- ### Example Output Format Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLatestWeight.md The weight sample object returned on success includes the weight value, and the start and end dates of the sample. ```json { "value": 200, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Example Body Fat Percentage Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getBodyFatPercentageSamples.md This is an example of the JSON structure returned for body fat percentage samples, including sample ID, value, start and end dates, and metadata. ```json [ { "id": "3d366e60-4f7c-4f72-b0ce-479ea19279b8", // The universally unique identifier (UUID) for this HealthKit object. "value": 16.5, "startDate": "2016-07-09T00:00:00.000-0400", "endDate": "2016-07-10T00:00:00.000-0400", "metadata": { "HKWasUserEntered": true, } }, { "id": "ba13089a-a311-4ffe-9352-f5c568936f16", "value": 16.1, "startDate": "2016-07-08T00:00:00.000-0400", "endDate": "2016-07-09T00:00:00.000-0400", "metadata": { "HKWasUserEntered": true, } }, { "id": "2292e713-636e-45a1-acd8-365397f6efed", "value": 15.9, "startDate": "2016-07-07T00:00:00.000-0400", "endDate": "2016-07-08T00:00:00.000-0400", "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Example Output for Energy Consumed Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getEnergyConsumedSamples.md This is an example of the data structure returned when successfully fetching energy consumed samples. ```json [ { "endDate": "2021-04-01T22:00:00.000+0300", "startDate": "2021-04-01T22:00:00.000+0300", "value": 204.5, "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Install iOS Dependencies with CocoaPods Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/Installation.md If using CocoaPods, navigate to the ios/ directory and run pod install. ```bash pod install ``` -------------------------------- ### Example Output for Daily Step Count Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDailyStepCountSamples.md The output is an array of objects, where each object represents daily step counts with start and end times, the total value, and metadata including the source. ```json [ { "endDate": "2021-03-22T17:00:00.000-0300", "startDate": "2021-03-22T16:00:00.000-0300", "value": 3978, "metadata": [ { "sourceId": "com.apple.Health", "sourceName": "Health", "quantity": 3978 } ] } ] ``` -------------------------------- ### Example Lean Body Mass Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLeanBodyMassSamples.md This is an example of the structure of the data returned when querying for lean body mass samples. ```json [ { "id": "ba13089a-a311-4ffe-9352-f5c568936f16", // The universally unique identifier (UUID) for this HealthKit object. "value": 160, "startDate": "2016-07-09T00:00:00.000-0400", "endDate": "2016-07-10T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } }, { "id": "b50407fa-44a7-4f12-9348-74c63748b38b", "value": 161, "startDate": "2016-07-08T00:00:00.000-0400", "endDate": "2016-07-09T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } }, { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", "value": 165, "startDate": "2016-07-07T00:00:00.000-0400", "endDate": "2016-07-08T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Output for Get Distance Cycling Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDistanceCycling.md The expected JSON structure for the cycling distance results. ```json { "value": 11.45, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Example Oxygen Saturation Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getOxygenSaturationSamples.md An example of the structure of the oxygen saturation samples returned by the API. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-04T10:56:00.000-0500", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-04T10:56:00.000-0500", "value": 0.98, "metadata": { "HKWasUserEntered": false } }, { "id": "86ff59e7-f393-4f32-95fb-b0bf7027374d", "endDate": "2021-03-04T09:55:00.000-0500", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-04T09:55:00.000-0500", "value": 0.97, "metadata": { "HKWasUserEntered": false } }, { "id": "b8239909-e519-4e33-af3e-d87db605ae97", "endDate": "2021-03-04T08:00:00.000-0500", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-04T08:00:00.000-0500", "value": 0.95, "metadata": { "HKWasUserEntered": false } }, { "id": "349fb170-86db-4857-9ffb-c70fb4510bac", "endDate": "2021-03-03T21:43:00.000-0500", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-03T21:43:00.000-0500", "value": 0.97, "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Waist Circumference Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWaistCircumferenceSamples.md An example of the data structure returned for waist circumference samples, including value, start and end dates, and metadata. ```json [ { "value": 39.02, "startDate": "2016-06-29T17:55:00.000-0400", "endDate": "2016-06-29T17:55:00.000-0400", "metadata": { "HKWasUserEntered": true, } }, { "value": 39, "startDate": "2016-03-12T13:22:00.000-0400", "endDate": "2016-03-12T13:22:00.000-0400", "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Example Height Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getHeightSamples.md Illustrates the structure of the data returned for height samples, including value, dates, and metadata. ```json [ { "id": "3d366e60-4f7c-4f72-b0ce-479ea19279b8", // The universally unique identifier (UUID) for this HealthKit object. "value": 74.02, "startDate": "2016-06-29T17:55:00.000-0400", "endDate": "2016-06-29T17:55:00.000-0400", "metadata": { "HKWasUserEntered": true, } }, { "id": "19a9910d-230a-437f-a830-353f6e61f676", "value": 74, "startDate": "2016-03-12T13:22:00.000-0400", "endDate": "2016-03-12T13:22:00.000-0400", "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Example Water Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWaterSamples.md The output is an array of objects, where each object represents a water sample entry with its ID, start and end dates, source information, and the consumed value. ```json [ { "id": "3d366e60-4f7c-4f72-b0ce-479ea19279b8", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-22T16:34:00.000-0300", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-22T15:34:00.000-0300", "value": "0.6" } ] ``` -------------------------------- ### Example Weight Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWeightSamples.md This is an example of the JSON structure returned by the getWeightSamples method, containing details for each weight sample. ```json [ { "id": "3d366e60-4f7c-4f72-b0ce-479ea19279b8", // The universally unique identifier (UUID) for this HealthKit object. "value": 160, "startDate": "2016-07-09T00:00:00.000-0400", "endDate": "2016-07-10T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } }, { "id": "cb7a2de6-f8d2-48cc-8cca-3d9f58a3601a", "value": 161, "startDate": "2016-07-08T00:00:00.000-0400", "endDate": "2016-07-09T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } }, { "id": "4dddd4da-2adf-4d1c-a400-10790ffe2c0d", "value": 165, "startDate": "2016-07-07T00:00:00.000-0400", "endDate": "2016-07-08T00:00:00.000-0400", "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveHeartRateSample.md The expected output when a Heart Rate sample is successfully saved. ```json 1 ``` -------------------------------- ### Example Carbohydrate Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getCarbohydratesSamples.md This is an example of the JSON structure returned for carbohydrate samples, including details like ID, dates, source, and value. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-22T16:21:00.000-0300", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-22T16:21:00.000-0300", "value": 8, "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Install react-native-health with Expo Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/Expo.md Use this command to install the package. This method is recommended for Expo projects as it ensures compatibility. ```bash expo install react-native-health ``` -------------------------------- ### Example Output of getFiberSamples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getFiberSamples.md Illustrates the structure of the data returned by `getFiberSamples`, including sample ID, dates, value, and metadata. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-04-01T22:00:00.000+0300", "startDate": "2021-04-01T22:00:00.000+0300", "value": 39, "metadata": { "HKWasUserEntered": true } } ] ``` -------------------------------- ### Example Insulin Delivery Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getInsulinDeliverySamples.md This is an example of the structure and data you can expect for an insulin delivery sample, including its ID, dates, source, value in International Units, and metadata. ```json [ { "id": "8DE6A905-02B7-41D2-BB6E-67D1DD82DD6F", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-22T16:19:00.000-0300", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-22T16:19:00.000-0300", "value": 5, "metadata": { "HKWasUserEntered": true, "HKInsulinDeliveryReason": 2, // Basal = 1, Bolus = 2 } } ] ``` -------------------------------- ### Example Output of Protein Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getProteinSamples.md The structure of the data returned when successfully retrieving protein samples. Each sample includes an ID, start and end dates, the protein value, and associated metadata. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-04-01T22:00:00.000+0300", "startDate": "2021-04-01T22:00:00.000+0300", "value": 39, "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Example Vo2Max Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getVo2MaxSamples.md An example of the structure for a single Vo2Max sample returned by the API, including its ID, dates, source information, value, and metadata. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-22T16:35:00.000-0300", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-22T16:35:00.000-0300", "value": 2, "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Output UUID Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveWorkout.md The method returns a UUID string upon successful saving of the workout. ```json A7D8E94A-5544-4533-869F-7566AAB81252 ``` -------------------------------- ### Example Body Temperature Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getBodyTemperatureSamples.md This is an example of the data structure returned for body temperature samples, including ID, value, timestamps, and metadata. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "value": 74.02, "startDate": "2016-06-29T17:55:00.000-0400", "endDate": "2016-06-29T17:55:00.000-0400", "metadata": { "HKWasUserEntered": true, } }, { "id": "1128b739-357d-4044-9205-3a287658aac1", "value": 74, "startDate": "2016-03-12T13:22:00.000-0400", "endDate": "2016-03-12T13:22:00.000-0400", "metadata": { "HKWasUserEntered": true, } } ] ``` -------------------------------- ### Example Output of saveFood Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveFood.md The expected output when food is successfully saved to HealthKit. ```json 16.7 ``` -------------------------------- ### Example Output of getWater Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWater.md The expected output format for the getWater method, showing an array of water intake records with their associated dates. ```json [ { "date": "2021-03-22T16:00:00.000-0300", } ] ``` -------------------------------- ### Configure Options for getAppleStandTime Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getAppleStandTime.md Define the start and end dates for retrieving standing time data. The start date is required, while the end date defaults to the current time. ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now } ``` -------------------------------- ### Example Output for Distance Data Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDistanceWalkingRunning.md The expected JSON structure for the distance walking/running data, including the value and time range. ```json { "value": 1.45, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Example Respiratory Rate Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getRespiratoryRateSamples.md Illustrates the structure of a single respiratory rate sample returned by the query. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "endDate": "2021-03-22T16:32:00.000-0300", "sourceId": "com.apple.Health", "sourceName": "Health", "startDate": "2021-03-22T16:32:00.000-0300", "value": 45, "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Output for saveHeight Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveHeight.md The expected output after successfully saving height data to HealthKit is the numeric value that was saved. ```json 200 ``` -------------------------------- ### Example Output (Record UUID) Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveInsulinDeliverySample.md The expected output upon successful saving of an insulin delivery sample is the UUID of the created record. ```json "619E37D3-C675-4186-B6A4-395EBFC6F46D" ``` -------------------------------- ### Example Output for Flights Climbed Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getFlightsClimbed.md The output provides the total `value` of flights climbed for the specified period, along with the `startDate` and `endDate` of the measurement. ```json { "value": 15, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Example Heartbeat Series Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getHeartbeatSeriesSamples.md Illustrates the structure of the data returned for heartbeat series samples, including timestamps and gap information. ```json [ { "id": "9728168D-CFD4-4946-BF94-2789ECD39A72", "sourceName": "Apple Watch", "startDate": "2021-07-10T08:55:31.307-0400", "endDate": "2021-07-10T08:56:34.731-0400", "sourceId": "com.apple.health", "heartbeatSeries": [ { "timeSinceSeriesStart": 0.97265625, "precededByGap": false }, { "timeSinceSeriesStart": 1.55859375, "precededByGap": false }, { "timeSinceSeriesStart": 2.16015625, "precededByGap": false }, { "timeSinceSeriesStart": 2.7421875, "precededByGap": false }, { "timeSinceSeriesStart": 3.3125, "precededByGap": false }, { "timeSinceSeriesStart": 3.89453125, "precededByGap": false }, { "timeSinceSeriesStart": 4.484375, "precededByGap": false }, { "timeSinceSeriesStart": 5.10546875, "precededByGap": false }, { "timeSinceSeriesStart": 5.7421875, "precededByGap": false }, { "timeSinceSeriesStart": 6.40234375, "precededByGap": false }, { "timeSinceSeriesStart": 7.0859375, "precededByGap": false }, { "timeSinceSeriesStart": 7.78125, "precededByGap": false }, { "timeSinceSeriesStart": 8.48046875, "precededByGap": false }, { "timeSinceSeriesStart": 9.16015625, "precededByGap": false }, { "timeSinceSeriesStart": 9.8203125, "precededByGap": false }, { "timeSinceSeriesStart": 10.48046875, "precededByGap": false }, { "timeSinceSeriesStart": 11.1171875, "precededByGap": false }, { "timeSinceSeriesStart": 11.73046875, "precededByGap": false }, { "timeSinceSeriesStart": 12.3359375, "precededByGap": false }, { "timeSinceSeriesStart": 12.91796875, "precededByGap": false }, { "timeSinceSeriesStart": 13.50390625, "precededByGap": false }, { "timeSinceSeriesStart": 14.09765625, "precededByGap": false }, { "timeSinceSeriesStart": 14.734375, "precededByGap": false }, { "timeSinceSeriesStart": 15.90625, "precededByGap": true } ] } ] ``` -------------------------------- ### Step Count Sample Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveSteps.md Define the options for a step count sample, including the value and the start and end dates of the measurement period. ```javascript let options = { value: 100, startDate: new Date(2016, 6, 2, 6, 0, 0).toISOString(), endDate: new Date(2016, 6, 2, 6, 30, 0).toISOString(), } ``` -------------------------------- ### Example Output for Step Count Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getStepCount.md The expected output from the getStepCount method is a JSON object containing the 'value' of the aggregated steps for the specified day. ```json { "value": 213 } ``` -------------------------------- ### Example Output for Get Distance Swimming Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDistanceSwimming.md The expected output format for swimming distance data, including the value, start date, and end date. ```json { "value": 20.03, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Configure Vo2Max Sample Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getVo2MaxSamples.md Set up the options object to define the parameters for retrieving Vo2Max samples. Ensure startDate is provided; other options like unit, endDate, ascending, and limit are optional. ```javascript let options = { unit: 'bpm', // optional; default 'ml/(kg * min)' startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Example Output of getMindfulSession Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getMindfulSession.md The `getMindfulSession` method returns an array of objects, each containing the start and end dates of a mindful session. ```json [ { "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" }, { "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ] ``` -------------------------------- ### Call getHeightSamples Method Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getHeightSamples.md Initiate the height sample query with the specified options and handle the response. ```javascript AppleHealthKit.getHeightSamples( options, (err: Object, results: Array) => { if (err) { return } console.log(results) }, ) ``` -------------------------------- ### Example Output of getTotalFatSamples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getTotalFatSamples.md The expected JSON structure for the results returned by getTotalFatSamples, including start and end dates, value, and metadata. ```json [ { "endDate": "2021-04-01T22:00:00.000+0300", "startDate": "2021-04-01T22:00:00.000+0300", "value": 39, "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Define Options for Getting Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getSamples.md Specify the date range and activity type for your sample query. Ensure dates are in ISO format and the type is one of the supported values. ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), endDate: new Date().toISOString(), type: 'Walking', // one of: ['Walking', 'StairClimbing', 'Running', 'Cycling', 'Workout'] } ``` -------------------------------- ### Configure Height Sample Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getHeightSamples.md Define the parameters for retrieving height samples. Options include unit, date range, and sorting. ```javascript let options = { unit: 'inch', // optional; default 'inch' startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Example Blood Pressure Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getBloodPressureSamples.md The output is an array of objects, each containing systolic and diastolic blood pressure values along with start and end dates. ```json [ { "bloodPressureSystolicValue": 120, "bloodPressureDiastolicValue": 81, "startDate": "2016-06-29T17:55:00.000-0400", "endDate": "2016-06-29T17:55:00.000-0400" }, { "bloodPressureSystolicValue": 119, "bloodPressureDiastolicValue": 77, "startDate": "2016-03-12T13:22:00.000-0400", "endDate": "2016-03-12T13:22:00.000-0400" } ] ``` -------------------------------- ### Example Output of getAppleStandTime Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getAppleStandTime.md The function returns an array of objects, where each object represents a period of standing time with its start date, end date, and the duration value. ```json [ { "endDate": "2021-03-22T16:00:00.000-0300", "startDate": "2021-03-22T15:00:00.000-0300", "value": 123 } ] ``` -------------------------------- ### Example Output of getActivitySummary Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getActivitySummary.md The method returns an array of objects, where each object represents the activity summary for a specific day, including active energy burned, exercise time, and stand hours, along with their goals. ```json [ { "activeEnergyBurned": 354, "activeEnergyBurnedGoal": 360, "appleExerciseTime": 16, "appleExerciseTimeGoal": 30, "appleStandHours": 10, "appleStandHoursGoal": 12 } ] ``` -------------------------------- ### Example Blood Alcohol Content Output (JSON) Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLatestBloodAlcoholContent.md The returned object contains the blood alcohol content value (as a percentage), and the exact start and end dates of the sample. ```json { "value": 0.001, "startDate": "2016-07-08T12:00:00.000-0400", "endDate": "2016-07-08T12:00:00.000-0400" } ``` -------------------------------- ### Configure Water Sample Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWaterSamples.md Define the parameters for fetching water samples, including units, date range, and inclusion of manually added data. Ensure startDate and endDate are provided. ```javascript let options = { unit: 'litre', // optional: default: litre startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // required includeManuallyAdded: false, // optional: default true ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Example Basal Energy Burned Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getBasalEnergyBurned.md Shows the expected JSON structure for basal energy burned data, including start and end dates and the energy value in kilocalories. ```json [ { "endDate": "2021-03-22T17:00:00.000-0300", "startDate": "2021-03-22T16:00:00.000-0300", "value": 42 } ] ``` -------------------------------- ### Configure Workout Route Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWorkoutRouteSamples.md Set up the options object to specify the workout ID for retrieving route samples. The ID is a required UUID. ```javascript let options = { id: 'E621E1F8-C36C-495A-93FC-0C247A3E6E5F', // required [UUID] } ``` -------------------------------- ### Example Output for Distance Swimming Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDailyDistanceSwimmingSamples.md The output is an array of objects, each representing a swimming distance sample. Values are typically in meters by default, and each sample includes start and end dates. ```json [ { "endDate": "2021-03-22T17:00:00.000-0300", "startDate": "2021-03-22T16:00:00.000-0300", "value": 91.44 } ] ``` -------------------------------- ### Set Up Oxygen Saturation Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getOxygenSaturationSamples.md Define the options for querying oxygen saturation samples. The startDate is required, while endDate, ascending, and limit are optional. ```javascript let options = { startDate: new Date(2021, 1, 1).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Get Latest Height Data Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLatestHeight.md Call this function to retrieve the most recent height measurement. The callback receives an error object if retrieval fails, or a results object containing the height value and its associated start and end dates. ```javascript AppleHealthKit.getLatestHeight(null, (err: string, results: HealthValue) => { if (err) { console.log('error getting latest height: ', err) return } console.log(results) }) ``` -------------------------------- ### Get Latest Weight Sample Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLatestWeight.md Call this method to retrieve the most recent weight sample. Provide options for units and a callback function to handle the results or errors. The callback receives a results object containing the weight value, start date, and end date. ```javascript let options = { unit: 'pound', } ``` ```javascript AppleHealthKit.getLatestWeight(options, (err: string, results: HealthValue) => { if (err) { console.log('error getting latest weight: ', err) return } console.log(results) }) ``` -------------------------------- ### Define Sleep Sample Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getSleepSamples.md Configure the options for querying sleep samples. Ensure startDate is provided. Optional parameters include endDate, limit, and ascending sort order. ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now limit: 10, // optional; default no limit ascending: true, // optional; default false } ``` -------------------------------- ### Get Latest BMI Data Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLatestBmi.md Call this function to retrieve the most recent BMI sample. The callback receives an error object or a results object containing the BMI value, start date, and end date. Note that startDate and endDate are identical for BMI samples. ```javascript AppleHealthKit.getLatestBmi(null, (err: string, results: HealthValue) => { if (err) { console.log('error getting latest bmi data: ', err) return } console.log(results) }) ``` -------------------------------- ### Configure Lean Body Mass Sample Query Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getLeanBodyMassSamples.md Define the options for querying lean body mass samples. Ensure `startDate` is provided. Other options like `unit`, `endDate`, `ascending`, and `limit` are optional. ```javascript let options = { unit: 'pound', // optional; default 'pound' startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Define Options for Step Count Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getStepCount.md Set up an options object to specify the date and whether to include manually added steps. If not provided, the current day and default inclusion of manual steps will be used. ```javascript let options = { date: new Date().toISOString(), // optional; default now includeManuallyAdded: false. // optional: default true }; ``` -------------------------------- ### Example Output for Distance Cycling Samples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDailyDistanceCyclingSamples.md The output provides an array of objects, where each object represents a distance cycling sample. The `value` is reported in meters by default. ```json [ { "endDate": "2021-03-22T17:00:00.000-0300", "startDate": "2021-03-22T16:00:00.000-0300", "value": 67592.448 } ] ``` -------------------------------- ### Define Options for Carbohydrate Sample Query Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getCarbohydratesSamples.md Configure query parameters such as unit, date range, and sorting. Ensure startDate is provided; endDate and other options are optional. ```javascript let options = { unit: 'gramUnit', // optional; default 'gram' startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit } ``` -------------------------------- ### Configure Options for getDailyDistanceCyclingSamples Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getDailyDistanceCyclingSamples.md Define the options object to configure the query for daily distance cycling samples. Ensure `startDate` is provided; `endDate`, `ascending`, `limit`, and `unit` are optional. ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 10, // optional; default no limit unit: 'meter', // optional; default meter } ``` -------------------------------- ### Configure ECG Sample Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getElectrocardiogramSamples.md Define the parameters for querying ECG samples, such as date range, sorting order, and limit. Ensure startDate is provided. ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now ascending: false, // optional; default false limit: 1, // optional; default no limit } ``` -------------------------------- ### Example Resting Heart Rate Sample Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getRestingHeartRateSamples.md An example of the structure of the data returned for resting heart rate samples, including ID, value, timestamps, and metadata. ```json [ { "id": "5013eca7-4aee-45af-83c1-dbe3696b2e51", // The universally unique identifier (UUID) for this HealthKit object. "value": 74, "startDate": "2016-03-12T13:22:00.000-0400", "endDate": "2016-03-12T13:22:00.000-0400", "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### Example Walking Heart Rate Average Output Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getWalkingHeartRateAverage.md This is an example of the JSON output structure for walking heart rate average values, including value, source information, and timestamps. ```json [ { "value": 77, "sourceId": "com.apple.health", "id": "6AFB1A69-0165-4495-9B9A-7C594B63D88C", "sourceName": "Source", "startDate": "2021-07-05T12:53:58.870-0400", "endDate": "2021-07-05T15:14:23.413-0400", "metadata": { "HKWasUserEntered": false } }, { "value": 73, "sourceId": "com.apple.health", "id": "A13D758C-DCD4-44FA-87A9-7DD63DED31F6", "sourceName": "Source", "startDate": "2021-07-04T00:00:25.881-0400", "endDate": "2021-07-04T11:39:15.130-0400", "metadata": { "HKWasUserEntered": false } } ] ``` -------------------------------- ### getActivitySummary Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/getActivitySummary.md Retrieves the move, exercise, and stand data for a specified date range. ```APIDOC ## getActivitySummary ### Description Retrieves the move, exercise, and stand data for a given day. ### Method `AppleHealthKit.getActivitySummary` ### Parameters #### Options Object - **startDate** (string) - Required - The start date for the summary data in ISOString format. - **endDate** (string) - Optional - The end date for the summary data in ISOString format. Defaults to the current date and time. ### Request Example ```javascript let options = { startDate: new Date(2021, 0, 0).toISOString(), // required endDate: new Date().toISOString(), // optional; default now } AppleHealthKit.getActivitySummary(options, (err, results) => { if (err) { // Handle error return; } // Process results console.log(results); }); ``` ### Response #### Success Response - **results** (Array) - An array of activity summary objects. `HealthActivitySummary` object structure: - **activeEnergyBurned** (number) - The amount of active energy burned. - **activeEnergyBurnedGoal** (number) - The goal for active energy burned. - **appleExerciseTime** (number) - The total Apple exercise time. - **appleExerciseTimeGoal** (number) - The goal for Apple exercise time. - **appleStandHours** (number) - The number of Apple stand hours. - **appleStandHoursGoal** (number) - The goal for Apple stand hours. ### Response Example ```json [ { "activeEnergyBurned": 354, "activeEnergyBurnedGoal": 360, "appleExerciseTime": 16, "appleExerciseTimeGoal": 30, "appleStandHours": 10, "appleStandHoursGoal": 12 } ] ``` ``` -------------------------------- ### Define Weight Data Options Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveWeight.md Define the options object for saving weight, including the numeric value, unit, and start date. The unit defaults to pounds and the start date defaults to the current time if not specified. ```javascript let options = { value: 200, unit: AppleHealthKit.Constants.Units.gram, // optional; default pounds startDate: new Date(2021, 0, 0).toISOString() // optional; default now } ``` -------------------------------- ### Add react-native-health Package Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/Installation.md Install the package using Yarn. ```bash yarn add react-native-health ``` -------------------------------- ### getAuthStatus Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/README.md Gets the authorization status for a given HealthKit data type. ```APIDOC ## getAuthStatus ### Description Gets the authorization status for a given HealthKit data type. ### Method Not specified (likely a function call in an SDK) ### Endpoint N/A ### Parameters #### Query Parameters - **type** (string) - Required - The HealthKit data type to check the authorization status for (e.g., 'Steps', 'Weight'). ### Request Example N/A ### Response #### Success Response - **status** (string) - The authorization status (e.g., 'authorized', 'denied', 'not_determined'). ``` -------------------------------- ### initHealthKit Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/initHealthKit.md Initializes HealthKit and prompts the user for permissions based on the provided options. Handles initialization errors and provides results. ```APIDOC ## initHealthKit ### Description Initializes HealthKit, which triggers the HealthKit permissions prompt for any read/write permissions specified in the `options` object. It also handles potential errors during initialization. ### Method `AppleHealthKit.initHealthKit(options, callback)` ### Parameters #### Options Object - **permissions** (object) - Required - An object containing `read` and `write` arrays of HealthKit data types. - **read** (array) - Optional - An array of strings representing data types to read from HealthKit. - **write** (array) - Optional - An array of strings representing data types to write to HealthKit. #### Callback Function - **err** (string) - An error message if initialization fails. - **results** (boolean) - A boolean indicating successful initialization. ### Request Example ```javascript let options = { permissions: { read: ['Height', 'Weight', 'StepCount', 'DateOfBirth', 'BodyMassIndex'], write: ['Weight', 'StepCount', 'BodyMassIndex'], }, } AppleHealthKit.initHealthKit(options, (err, results) => { if (err) { console.log('error initializing Healthkit: ', err) return } // Healthkit is initialized... // now safe to read and write Healthkit data... }) ``` ### Response #### Success Response (results: true) Indicates that HealthKit has been successfully initialized and is ready for data operations. #### Error Response (err) Provides an error message if HealthKit initialization fails. This could be due to various reasons, including user denial of permissions or system issues. ``` -------------------------------- ### Example Output of saveBodyTemperature Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/saveBodyTemperature.md The expected output when the body temperature is successfully saved. ```json 96 ``` -------------------------------- ### Initialize HealthKit Source: https://github.com/agencyenterprise/react-native-health/blob/master/docs/initHealthKit.md Call `initHealthKit` with your defined options to prompt the user for HealthKit permissions. The callback handles initialization success or errors. ```javascript AppleHealthKit.initHealthKit( (options: HealthInputOptions), (err: string, results: boolean) => { if (err) { console.log('error initializing Healthkit: ', err) return } // Healthkit is initialized... // now safe to read and write Healthkit data... }, ) ```