Code Monkey home page Code Monkey logo

react-native-samsung-health's Introduction

react-native-samsung-health

React Native bridge module for interacting with Samsung Health

Installing it as a library in your main project

There are many ways to do this:

  1. Do npm install --save git+http://gitlab.synclab.it/ios/react-native-samsungHealth.git in your main project.

  2. Link the library:

    • Add the following to android/settings.gradle:

      include ':react-native-samsung-health'
      project(':react-native-samsung-health').projectDir = new File(settingsDir, '../node_modules/react-native-samsung-health/android')
      
    • Add the following to android/app/build.gradle:

      ...
      
      dependencies {
          ...
          compile project(':react-native-samsung-health')
      }
    • Add the following to android/app/src/main/java/**/MainApplication.java:

      package com.example;
      
      import com.reactnative.samsunghealth.SamsungHealthPackage;  // add this for react-native-samsung-health
      
      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 for react-native-samsung-health
              );
          }
      }
    • Add permission in android/app/src/main/AndroidManifest.xml:

      <application
      
      <meta-data
        android:name="com.samsung.android.health.permission.read"
        android:value="com.samsung.health.step_count;com.samsung.shealth.step_daily_trend" />
  3. Simply import/require it by the name defined in your library's package.json:

    import SamsungHealth from 'react-native-samsung-health'
    
    SamsungHealth.authorize((err, res) => {
      if (res) {
        let opt = {};
        SamsungHealth.getDailyStepCountSamples(opt, (err, res) => {
          if (err) console.log(err);
          if (res) console.log(res);
        });
      } else console.log(err);
    });

Modify/Build the Project in Android Studio

  • Start Android Studio and select File -> New -> Import Project and select the android folder of this package.
  • If you get a Plugin with id 'android-library' not found Error, install android support repository.
  • If you get asked to upgrade gradle to a new version, you can skip it.

Access Data without S Health partner app certification

If you want to test your app on your device but you don't have the Samsung app certification you'll see an error that looks like

java.lang.SecurityException: Denied to access by whitelist

this error is because to work with S Health you app must be certified, to prevent this error for local development you can enable the developer mode on the Samsun Healt app, go to

Settings -> About Samsung Health

and tap 10 times on the app version, the name of the version will then change to *(Developer Mode)* and you'll be able to access S Health data

react-native-samsung-health's People

Contributors

firodj avatar matteo-hertel avatar

Watchers

James Cloos avatar  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.