Skip to content

SynappzMA/iHealth-React-Native-SDK

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iHealth device sdk

Installation

Using npm

npm install --save @ihealth/ihealthlibrary-react-native

Using yarn

yarn add @ihealth/ihealthlibrary-react-native

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

  • iOS Platform:

    $ npx pod-install # CocoaPods on iOS needs this extra step

  • Android Platform with Android Support:

    Using Jetifier tool for backward-compatibility if needed

Using React Native < 0.60

You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:

react-native link @ihealth/ihealthlibrary-react-native

If you can't or don't want to use the CLI tool, you can also manually link the library using the instructions below (click on the arrow to show them):

Manually link the library on iOS

Either follow the instructions in the React Native documentation to manually link the framework or link using Cocoapods by adding this to your Podfile:

pod 'ihealth', :path => '../node_modules/@ihealth/ihealthlibrary-react-native'
Manually link the library on Android

Make the following changes:

android/settings.gradle

include ':ihealthlibrary-react-native'
project(':ihealthlibrary-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/@ihealth/ihealthlibrary-react-native/android')

android/app/build.gradle

dependencies {
   ...
   implementation project(':ihealthlibrary-react-native')
}◊

android/app/src/main/.../MainActivity.java

Import iHealth module in your MainActivity.java

protected List<ReactPackage> getPackages() {  
	return Arrays.<ReactPackage>asList(
		new MainReactPackage(),
		new iHealthDeviceManagerPackage()
	);  
}

Android permissions

Location permission (in AndroidManifest.xml)

<!-- Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in Android API 23+ -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Usage

Authentication

Download license file

  1. Sign up iHealth developer webside. Please sign up here
  2. Press "Add New App" button, fill in your information of your app. We will get email and active the license for your app.
  3. Download license file, as shown below. Download

Integrate license file

For iOS As shown below, Add your license file to your iOS project. �integrate ios

For Android As show below, Add your license file to your asserts �folder. �integrate android

Using license file

import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';

// your license file
const filename = 'license.pem';
iHealthDeviceManagerModule.sdkAuthWithLicense(filename);

Example

iHealth SDK module is based on DeviceEventEmitter, So call add listener while the component is loaded, and call remove listener while the component is unloaded, As shown below

import { DeviceEventEmitter } from 'react-native';
import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';

componentDidMount() {
    DeviceEventEmitter.addListener(
      iHealthDeviceManagerModule.Event_Authenticate_Result, (event) => {  }
  	);
}

componentWillUnmount() {
    DeviceEventEmitter.removeListener(iHealthDeviceManagerModule.Event_Authenticate_Result);
}

For bluetooth LE or regular bluetooth device

search device
import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
const type = 'BP5'; // AM3S, AM4, BG5, BG5S, BP3L, BP5, BP5S, BP7S, HS2, HS4S, PO3,HS2S,BG1S
iHealthDeviceManagerModule.startDiscovery(type);
connect device
import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
const mac = 'xxxxxxxxxxxxxx';
const type = 'BP5'; // AM3S, AM4, BG5, BG5S, BP3L, BP5, BP5S, BP7S, HS2, HS4S, PO3,HS2S,BG1S
iHealthDeviceManagerModule.connectDevice(mac, type);
device workflow

AM3S workflow AM4 workflow BG1 workflow BG5 workflow BG5S workflow BP3L workflow BP5 workflow BP5S workflow BP7S workflow HS2 workflow HS4S workflow HS6 workflow PO3 workflow HS2S workflow BG1S workflow

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 48.0%
  • Objective-C 37.0%
  • Java 9.3%
  • JavaScript 4.9%
  • C 0.5%
  • CSS 0.3%