react-native-spike-sdk 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ More details you can find [here](https://developer.apple.com/documentation/healt
|
|
|
58
58
|
|
|
59
59
|
### Info.plist
|
|
60
60
|
|
|
61
|
-
Add Health Kit permissions descriptions to your Info.plist file.
|
|
61
|
+
Add Health Kit permissions descriptions to your `Info.plist` file.
|
|
62
62
|
|
|
63
63
|
```xml
|
|
64
64
|
<key>NSHealthShareUsageDescription</key>
|
|
@@ -133,7 +133,7 @@ All Spike SDK async method calls should be wrapped into try catch block.
|
|
|
133
133
|
### 1. Create Spike connection <a name="create_connection"></a>
|
|
134
134
|
|
|
135
135
|
To set up the Spike SDK create [SpikeConnection](#class_SpikeConnection) instance with [SpikeConnectionConfig](#type_SpikeConnectionConfig) object.
|
|
136
|
-
From the
|
|
136
|
+
From the 2.1.x version Spike SDK automatically manages connection persistance and restore connection if finds one with same `appId`, `authToken` and `customerEndUserId`.
|
|
137
137
|
With each new connection creating call `callbackUrl` and `env` could be overridden.
|
|
138
138
|
Provide [SpikeLogger](#class_SpikeLogger) implementation to handle connection logs.
|
|
139
139
|
|
|
@@ -160,12 +160,16 @@ Provide permissions to access iOS HealthKit and Android HealthConnect data. Spik
|
|
|
160
160
|
// conn was created in the previous step
|
|
161
161
|
|
|
162
162
|
if (Platform.OS === 'android') {
|
|
163
|
-
|
|
163
|
+
// Android methods should be called on connection instance
|
|
164
|
+
const isGranted = await conn.checkPermissionsGranted();
|
|
165
|
+
if (!isGranted) {
|
|
166
|
+
await conn.requestHealthPermissions();
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
if (Platform.OS === 'ios') {
|
|
171
|
+
// iOS method should be called on Spike class
|
|
167
172
|
await Spike.ensurePermissionsAreGranted([
|
|
168
|
-
// Method should be called on Spike class
|
|
169
173
|
SpikeDataTypes.activitiesStream,
|
|
170
174
|
SpikeDataTypes.steps,
|
|
171
175
|
]); // Provide required Spike data types
|
|
@@ -178,7 +182,7 @@ There are two ways to get Spike data: to your webhook or directly in your app. E
|
|
|
178
182
|
|
|
179
183
|
#### Extract data locally
|
|
180
184
|
|
|
181
|
-
According to the provided [SpikeDataType](#spike_data_types) result object may be different.
|
|
185
|
+
According to the provided [SpikeDataType](#spike_data_types) result object may be different.
|
|
182
186
|
|
|
183
187
|
```javascript
|
|
184
188
|
// conn was created in the previous step
|
|
@@ -194,7 +198,8 @@ const data = await conn.extractData({
|
|
|
194
198
|
|
|
195
199
|
// Extract steps data for yesterday and today.
|
|
196
200
|
const today = new Date();
|
|
197
|
-
const yesterday = new Date()
|
|
201
|
+
const yesterday = new Date();
|
|
202
|
+
yesterday.setDate(today.getDate() - 1);
|
|
198
203
|
const data = await conn.extractData({
|
|
199
204
|
dataType: SpikeDataTypes.steps,
|
|
200
205
|
from: yesterday,
|
|
@@ -221,7 +226,8 @@ const data = await conn.extractAndPostData({
|
|
|
221
226
|
|
|
222
227
|
// Send yesterday's and today's steps data to webhook
|
|
223
228
|
const today = new Date();
|
|
224
|
-
const yesterday = new Date()
|
|
229
|
+
const yesterday = new Date();
|
|
230
|
+
yesterday.setDate(today.getDate() - 1);
|
|
225
231
|
const data = await conn.extractAndPostData({
|
|
226
232
|
dataType: SpikeDataTypes.steps,
|
|
227
233
|
from: yesterday,
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
|
|
|
5
5
|
|
|
6
6
|
Pod::Spec.new do |s|
|
|
7
7
|
s.name = "react-native-spike-sdk"
|
|
8
|
-
s.version = "2.1.
|
|
8
|
+
s.version = "2.1.2"
|
|
9
9
|
s.summary = "Spike API for health and productivity data from wearables and IoT devices"
|
|
10
10
|
|
|
11
11
|
s.description = <<-DESC
|