summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/README.md')
-rwxr-xr-xlibs/ihealth-sdk/README.md138
1 files changed, 138 insertions, 0 deletions
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 @@
1# iHealth device sdk
2
3## Installation
4
5### Using npm
6
7```shell
8npm install --save @ihealth/ihealthlibrary-react-native
9```
10
11### Using yarn
12
13```shell
14yarn add @ihealth/ihealthlibrary-react-native
15```
16
17## Usage
18
19### Authentication
20
21#### Download license file
22
231. Sign up iHealth developer webside. [Please sign up here](https://dev.ihealthlabs.com)
242. Press "Add New App" button, fill in your information of your app. We will get email and active the license for your app.
253. Download license file, as shown below.
26![Download](./doc/download.png)
27
28#### Integrate license file
29
30For iOS
31As shown below, Add your license file to your iOS project.
32![integrate ios](./doc/integrate-ios.png)
33
34For Android
35As show below, Add your license file to your asserts folder.
36![integrate android](./doc/integrate-android.png)
37
38#### Using license file
39
40```js
41import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
42
43// your license file
44const filename = 'license.pem';
45iHealthDeviceManagerModule.sdkAuthWithLicense(filename);
46```
47
48### Troubleshooting
49
50#### For Android
51
521. Check settings.gradle file in your android project and node_modules, make sure input the correct module path.
53
54```gradle
55include ':ihealthlibrary-react-native'
56project(':ihealthlibrary-react-native').projectDir = new File(rootProject.projectDir,'../node_modules/@ihealth/ihealthlibrary-react-native/android')
57```
58
592. Check build.gradle file in your android project, make sure the ihealth module is integrated
60
61```gradle
62compile project(':@ihealth_ihealthlibrary-react-native')
63```
64
653. Import iHealth module in your MainActivity.java
66
67```java
68protected List<ReactPackage> getPackages() {
69 return Arrays.<ReactPackage>asList(
70 new MainReactPackage(),
71 new iHealthDeviceManagerPackage()
72 );
73}
74```
75
764. Location permission(in AndroidManifest.xml)
77
78```xml
79<!-- Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in Android API 23+ -->
80<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
81<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
82```
83
84#### For iOS
85
861. Open your iOS project, add node_modules/@ihealth/ihealthlibrary-react-native/ios/ReactNativeIOSLibrary.xcodeproj to libraries
872. Under 'Build Phases' -- 'Link Binary With Libraries', add libReactNativeIOSLibrary.a
88
89### Example
90
91iHealth 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.
92
93```js
94componentDidMount() {
95 iHealthAPI.addListener();
96}
97
98componentWillUnmount() {
99 iHealthAPI.removeListener();
100}
101```
102
103#### For bluetooth LE or regular bluetooth device
104
105##### search device
106
107```js
108import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
109const type = 'BP5'; // AM3S, AM4, BG5, BG5S, BP3L, BP5, BP5S, BP7S, HS2, HS4S, PO3,HS2S,BG1S
110iHealthDeviceManagerModule.startDiscovery(type);
111```
112
113##### connect device
114
115```js
116import { iHealthDeviceManagerModule } from '@ihealth/ihealthlibrary-react-native';
117const mac = 'xxxxxxxxxxxxxx';
118const type = 'BP5'; // AM3S, AM4, BG5, BG5S, BP3L, BP5, BP5S, BP7S, HS2, HS4S, PO3,HS2S,BG1S
119iHealthDeviceManagerModule.connectDevice(mac, type);
120```
121
122##### device workflow
123
124[AM3S workflow](./doc/am3s.md)
125[AM4 workflow](./doc/am4.md)
126[BG1 workflow](./doc/bg1.md)
127[BG5 workflow](./doc/bg5.md)
128[BG5S workflow](./doc/bg5s.md)
129[BP3L workflow](./doc/bp3l.md)
130[BP5 workflow](./doc/bp5.md)
131[BP5S workflow](./doc/bp5s.md)
132[BP7S workflow](./doc/bp7s.md)
133[HS2 workflow](./doc/hs2.md)
134[HS4S workflow](./doc/hs4s.md)
135[HS6 workflow](./doc/hs6.md)
136[PO3 workflow](./doc/po3.md)
137[HS2S workflow](./doc/hs2s.md)
138[BG1S workflow](./doc/bg1s.md)