react-native-spike-sdk 2.1.0 → 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 1.1.x version Spike SDK automatically manages connection persistance and restore connection if finds one with same `appId`, `authToken` and `customerEndUserId`.
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
- await conn.checkPermissionsGranted(); // Method should be called on connection instance
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. See all Spike Data Entry objects here.
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().setDate(today.getDate() - 1);
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().setDate(today.getDate() - 1);
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,
@@ -76,7 +76,7 @@ dependencies {
76
76
  //noinspection GradleDynamicVersion
77
77
  implementation "com.facebook.react:react-android:0.71.3"
78
78
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
79
- implementation 'com.spikeapi.sdk:spike-sdk:2.1.0'
79
+ implementation 'com.spikeapi.sdk:spike-sdk:2.3.2'
80
80
  implementation 'androidx.core:core-ktx:1.9.0'
81
81
  implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
82
82
  implementation 'com.google.code.gson:gson:2.10.1'
@@ -42,7 +42,7 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
42
42
  appId: String,
43
43
  authToken: String,
44
44
  customerEndUserId: String,
45
- callbackUrl: String,
45
+ callbackUrl: String?,
46
46
  env: String,
47
47
  useLogger: Boolean,
48
48
  promise: Promise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-spike-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Spike API for health and productivity data from wearables and IoT devices",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -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.0"
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