Code Monkey home page Code Monkey logo

rn-samsung-health's Introduction

rn-samsung-health

React-Native module to read health data from samsung-health application on android device, using samsung health android sdk.

Installation

npm i -S rn-samsung-health

Getting started

  • Add to your {YourApp}/android/settings.gradle:
include ':rn-samsung-health'
        project(':rn-samsung-health').projectDir = new File(settingsDir, '../node_modules/rn-samsung-health/android')
  • Add dependency to your android/app/build.gradle file:
dependencies {
                ...
               compile project(':rn-samsung-health')         // add this line
        }
  • Add following code to android/app/src/main/java/**/MainApplication.java:
import com.reactnative.samsunghealth.SamsungHealthPackage;  // add this line

public class MainApplication extends Application implements ReactApplication {
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            .....,
            new SamsungHealthPackage(BuildConfig.APPLICATION_ID)  // add this line
            );
    }
}
  • Add permissions in android/app/src/main/AndroidManifest.xml:
        <application
        <meta-data
          android:name="com.samsung.android.health.permission.read"
          android:value="com.samsung.health.weight;com.samsung.health.step_count;com.samsung.shealth.step_daily_trend;com.samsung.health.height;com.samsung.health.blood_pressure;com.samsung.health.heart_rate;com.samsung.health.sleep;com.samsung.health.body_temperature;" />

Usage

    import RNSamsungHealth from 'rn-samsung-health'

    RNSamsungHealth.authorize((err, res) => {
      if (res) {
       let startDate = new Date().setDate(new Date().getDate()-30); // 30 days back date
       let endDate = new Date().getTime(); //today's date
        let opt = {startDate, endDate};
        RNSamsungHealth.getDailyStepCount(opt, (err, res) => {
          if (err) console.log(err);
          if (res) console.log(res);
        });


// more similar functions are - 
    //getDailyStepCount
    //getHeight
    //getWeight
    //getSleep
    //getCholesterol
    //getBloodPressure
    //getBodyTemprature

      } else console.log(err);
    });
    
    
    
    
    

Developer Mode on Samsung Health app

You need Samsung app certification to access all health data provided by Ssamsung Health application. You can apply for Samsung partner apps for your react-native application. For more details please visit Samsung Health Android SDK

For development purpose you can enable the developer mode on Samsung Health app:

Open Samsung Health application

Go to > Settings > About Samsung Health

Tap 10 times on the app version Version XX.XX.

The name of the version will be changed to *(Developer Mode)* XXXX Version XX.XX and you'll be able to access S Health data.

Feel free to report issues here.

rn-samsung-health's People

Contributors

yatsyshynlits avatar ganeshsinghpapola avatar fstefanello avatar ravishankar3961 avatar ykliuiev avatar roylee0704 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.