From d6d9a09d505d11148599a95a5be3e1351edbe0ac Mon Sep 17 00:00:00 2001 From: hc Date: Mon, 13 Apr 2026 15:17:52 +0800 Subject: Local iHealth SDK, device detail screen, iOS event fixes --- libs/ihealth-sdk/README.md | 138 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 libs/ihealth-sdk/README.md (limited to 'libs/ihealth-sdk/README.md') diff --git a/libs/ihealth-sdk/README.md b/libs/ihealth-sdk/README.md new file mode 100755 index 0000000..a862013 --- /dev/null +++ b/libs/ihealth-sdk/README.md @@ -0,0 +1,138 @@ +# iHealth device sdk + +## Installation + +### Using npm + +```shell +npm install --save @ihealth/ihealthlibrary-react-native +``` + +### Using yarn + +```shell +yarn add @ihealth/ihealthlibrary-react-native +``` + +## Usage + +### Authentication + +#### Download license file + +1. Sign up iHealth developer webside. [Please sign up here](https://dev.ihealthlabs.com) +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](./doc/download.png) + +#### Integrate license file + +For iOS +As shown below, Add your license file to your iOS project. +![integrate ios](./doc/integrate-ios.png) + +For Android +As show below, Add your license file to your asserts folder. +![integrate android](./doc/integrate-android.png) + +#### Using license file + +```js +import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native'; + +// your license file +const filename = 'license.pem'; +iHealthDeviceManagerModule.sdkAuthWithLicense(filename); +``` + +### Troubleshooting + +#### For Android + +1. Check settings.gradle file in your android project and node_modules, make sure input the correct module path. + +```gradle +include ':ihealthlibrary-react-native' +project(':ihealthlibrary-react-native').projectDir = new File(rootProject.projectDir,'../node_modules/@ihealth/ihealthlibrary-react-native/android') +``` + +2. Check build.gradle file in your android project, make sure the ihealth module is integrated + +```gradle +compile project(':@ihealth_ihealthlibrary-react-native') +``` + +3. Import iHealth module in your MainActivity.java + +```java +protected List getPackages() { + return Arrays.asList( + new MainReactPackage(), + new iHealthDeviceManagerPackage() + ); +} +``` + +4. Location permission(in AndroidManifest.xml) + +```xml + + + +``` + +#### For iOS + +1. Open your iOS project, add node_modules/@ihealth/ihealthlibrary-react-native/ios/ReactNativeIOSLibrary.xcodeproj to libraries +2. Under 'Build Phases' -- 'Link Binary With Libraries', add libReactNativeIOSLibrary.a + +### 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 show as below. If you want more detail information, Please the example code. + +```js +componentDidMount() { + iHealthAPI.addListener(); +} + +componentWillUnmount() { + iHealthAPI.removeListener(); +} +``` + +#### For bluetooth LE or regular bluetooth device + +##### search device + +```js +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 + +```js +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](./doc/am3s.md) +[AM4 workflow](./doc/am4.md) +[BG1 workflow](./doc/bg1.md) +[BG5 workflow](./doc/bg5.md) +[BG5S workflow](./doc/bg5s.md) +[BP3L workflow](./doc/bp3l.md) +[BP5 workflow](./doc/bp5.md) +[BP5S workflow](./doc/bp5s.md) +[BP7S workflow](./doc/bp7s.md) +[HS2 workflow](./doc/hs2.md) +[HS4S workflow](./doc/hs4s.md) +[HS6 workflow](./doc/hs6.md) +[PO3 workflow](./doc/po3.md) +[HS2S workflow](./doc/hs2s.md) +[BG1S workflow](./doc/bg1s.md) -- cgit