npm install --save @ihealth/ihealthlibrary-react-native
yarn add @ihealth/ihealthlibrary-react-native
For iOS As shown below, Add your license file to your iOS project.
For Android As show below, Add your license file to your asserts folder.
import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
// your license file
const filename = 'license.pem';
iHealthDeviceManagerModule.sdkAuthWithLicense(filename);
include ':ihealthlibrary-react-native'
project(':ihealthlibrary-react-native').projectDir = new File(rootProject.projectDir,'../node_modules/@ihealth/ihealthlibrary-react-native/android')
compile project(':@ihealth_ihealthlibrary-react-native')
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new iHealthDeviceManagerPackage()
);
}
<!-- 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" />
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 show as below. If you want more detail information, Please the example code.
componentDidMount() {
iHealthAPI.addListener();
}
componentWillUnmount() {
iHealthAPI.removeListener();
}
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);
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);
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