All Projects → agencyenterprise → react-native-health

agencyenterprise / react-native-health

Licence: MIT license
A React Native package to interact with Apple HealthKit

Programming Languages

objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to react-native-health

rn-fitness-tracker
React Native module to interact with Google Fit and Apple HealthKit.
Stars: ✭ 58 (-83.33%)
Mutual labels:  fitness, health, healthkit
health kit reporter
A Flutter wrapper for the HealthKitReporter library
Stars: ✭ 16 (-95.4%)
Mutual labels:  health, healthkit
Tapiriik
tapiriik keeps your fitness in sync
Stars: ✭ 1,604 (+360.92%)
Mutual labels:  fitness, health
Health Blockchain
A blockchain for fitness data demo
Stars: ✭ 31 (-91.09%)
Mutual labels:  fitness, health
Hitrava
Convert your Huawei Health sport activities and import them in Strava.
Stars: ✭ 156 (-55.17%)
Mutual labels:  fitness, health
Mining-Minds
Mining Minds is a collection of services, tools and techniques working collaboratively to investigate on human’s daily routines to provide a personalized well-being and health-care support
Stars: ✭ 43 (-87.64%)
Mutual labels:  health, healthkit
HealthKitReporter
HealthKitReporter. A wrapper for HealthKit framework. Helps to write or read data from Apple Health via HealthKit framework.
Stars: ✭ 50 (-85.63%)
Mutual labels:  health, healthkit
hms-health-demo-java
HMS Health demo code provides demo programs for your reference or usage. Developers can access the Huawei Health Platform and obtain sports & health data by integrating HUAWEI Health.
Stars: ✭ 37 (-89.37%)
Mutual labels:  fitness, health
hms-health-demo-kotlin
HMS Health demo code provides demo programs for your reference or usage. Developers can access the Huawei Health Platform and obtain sports & health data by integrating HUAWEI Health.
Stars: ✭ 21 (-93.97%)
Mutual labels:  fitness, health
environmental-exposure-ontology
Modular environmental exposures ontology
Stars: ✭ 20 (-94.25%)
Mutual labels:  health
calories-in
A web-based meal plan editor for people who prepare all of their food.
Stars: ✭ 105 (-69.83%)
Mutual labels:  fitness
MuscleBook
[ABANDONED] Muscle Book is an iOS workout tracker for strength training and body building.
Stars: ✭ 36 (-89.66%)
Mutual labels:  fitness
flutter
Flutter fitness/workout app for wger
Stars: ✭ 106 (-69.54%)
Mutual labels:  fitness
tdee-calculator
TDEE Calculator is a composer library that calculates how much energy (calories) are burned daily given the weight, height and age or Lean Body Mass.
Stars: ✭ 16 (-95.4%)
Mutual labels:  health
PanFLUte
An open source spirometer for everyone.
Stars: ✭ 14 (-95.98%)
Mutual labels:  health
health-go
A golang implementation of the upcoming IETF RFC Health Check Response Format for HTTP APIs
Stars: ✭ 31 (-91.09%)
Mutual labels:  health
lifescripts
Automating various decisions stochastically, starting with my current coin-based intermittent fasting and dice-based kettlebell.
Stars: ✭ 20 (-94.25%)
Mutual labels:  fitness
exhale
A Pebble app for breathing, written in C.
Stars: ✭ 12 (-96.55%)
Mutual labels:  health
healthkit-to-sqlite
Convert an Apple Healthkit export zip to a SQLite database
Stars: ✭ 130 (-62.64%)
Mutual labels:  healthkit
nightnight
nightnight is a simple program that puts your website to sleep, encouraging users to sleep to promote their health and well being.
Stars: ✭ 57 (-83.62%)
Mutual labels:  health

React Native Health

A React Native package to interact with Apple HealthKit for iOS.

Getting Started

🚨 Expo: This package is not available in the Expo Go app. Learn how you can use it with custom dev clients.

Automatic Installation

  1. Install the react-native-health package from npm
yarn add react-native-health
  1. If you are using CocoaPods you can run the following from the ios/ folder of your app
pod install

Or, if you need to manually link it, run

react-native link react-native-health
  1. Update the ios/<Project Name>/info.plist file in your project
<key>NSHealthShareUsageDescription</key>
<string>Read and understand health data.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Share workout data with other apps.</string>
<!-- Below is only required if requesting clinical health data -->
<key>NSHealthClinicalHealthRecordsShareUsageDescription</key>
<string>Read and understand clinical health data.</string>

To add Healthkit support to your application's Capabilities

  • Open the ios/ folder of your project in Xcode
  • Select the project name in the left sidebar
  • In the main view select '+ Capability' and double click 'HealthKit'

To enable access to clinical data types, check the Clinical Health Records box.

Usage

In order to start collecting or saving data to HealthKit, you need to request the user's permissions for the given data types. It can be done in the following way

import AppleHealthKit, {
  HealthValue,
  HealthKitPermissions,
} from 'react-native-health'

/* Permission options */
const permissions = {
  permissions: {
    read: [AppleHealthKit.Constants.Permissions.HeartRate],
    write: [AppleHealthKit.Constants.Permissions.Steps],
  },
} as HealthKitPermissions

AppleHealthKit.initHealthKit(permissions, (error: string) => {
  /* Called after we receive a response from the system */

  if (error) {
    console.log('[ERROR] Cannot grant permissions!')
  }

  /* Can now read or write to HealthKit */

  const options = {
    startDate: new Date(2020, 1, 1).toISOString(),
  }

  AppleHealthKit.getHeartRateSamples(
    options,
    (callbackError: string, results: HealthValue[]) => {
      /* Samples are now collected from HealthKit */
    },
  )
})

Background Processing

For background capabilities, Apple allows developers to setup long running observer queries for the health types needed.

To setup that in your app, in XCode open your ios/AppDelegate.m file and add the following statements:

#import "AppDelegate.h"

...

/* Add the library import at the top of AppDelegate.m */
#import "RCTAppleHealthKit.h"

...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                            launchOptions:launchOptions];

  ...

  /* Add Background initializer for HealthKit  */
  [[RCTAppleHealthKit new] initializeBackgroundObservers:bridge];

  ...

  return YES;
}

After that you can start listening for data updates using the React Native client. For more information, see background observers.

Documentation

There is a gitbook version for the documentation on this link.

All the documentation is under the docs folder. Additionally, they are splitted in the following categories

Constants

Base Methods

Background Methods

Activity Methods

Body Methods

Characteristic Methods

Clinical Records Methods

Dietary Methods

Fitness Methods

Hearing Methods

Lab Tests Methods

Nutrition

Mindfulness Methods

Sleep Methods

Vitals Methods

Workout Methods

Additional Information

Permissions

Due to Apple's privacy model, if a user has previously denied a specific permission they will not be prompted again for that permission. The user will need to go into the Apple Health app and grant the permission to your app.

For any data written to Healthkit, an authorization error can be caught. If an authorization error occurs, you can prompt the user to set the specific permission or add the permission to the options object when initializing the library.

If extra read or write permissions are added to the options object, the app will request for user's permission to them when the library is initialized again.

Manual Installation

  1. Run yarn add react-native-health
  2. In XCode, in the project navigator, right-click LibrariesAdd Files to [your project's name]
  3. Go to node_modulesreact-native-health and add RCTAppleHealthkit.xcodeproj
  4. In XCode, in the project navigator, select your project. Add libRCTAppleHealthkit.a to your project's Build PhasesLink Binary With Libraries
  5. Click RCTAppleHealthkit.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). In the Search Paths section, look for Header Search Paths and make sure it contains both $(SRCROOT)/../../react-native/React and $(SRCROOT)/../../../React - mark both as recursive.
  6. Enable Healthkit in your application's Capabilities
  7. Compile and run

Contributing

We appreciate any additional request and/or contribution to react-native-health. The issues tracker is used to keep a list of features and bugs to be worked on. Please see our contributing documentation for some tips on getting started.

References

Acknowledgement

This package is a fork of rn-apple-healthkit

This package also inherits additional features from Nutrisense fork

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].