npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-samsung-health-android

v1.0.0

Published

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

Downloads

8

Readme

rn-samsung-health-android

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-android

Getting started

If you are using RN >= 0.60 then no need to do further steps. Thanks to Autolinking feature.

For manual linking

  • Add to your {YourApp}/android/settings.gradle:
include ':rn-samsung-health-android'
        project(':rn-samsung-health-android').projectDir = new File(settingsDir, '../node_modules/rn-samsung-health-android/android')
  • Add dependency to your android/app/build.gradle file:
dependencies {
                ...
               compile project(':rn-samsung-health-android')         // 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-android'

    useEffect(()=>{
      health();
    },[])
    const health = async() => {
      try{
        const auth = await RNSamsungHealth.authorize();
        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};
        const steps = await RNSamsungHealth.getDailyStepCount(opt);

      }catch(error){
        console.log("error ", error)
      }
    }
    // more similar functions are - 
    //getDailyStepCount
    //getHeight
    //getWeight
    //getSleep
    //getCholesterol
    //getBloodPressure
    //getBodyTemperature



    // old method 
    // 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);
    //     });




    //   } 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.