react-native-spike-sdk 4.4.13 → 4.5.23-beta.1
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/android/build.gradle +3 -1
- package/android/src/main/java/com/spikesdk/SpikeSdkModule.kt +96 -1
- package/ios/SpikeSdk.m +19 -0
- package/ios/SpikeSdk.swift +123 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/v3/RecordConfig.js +16 -0
- package/lib/commonjs/v3/RecordConfig.js.map +1 -0
- package/lib/commonjs/v3/SpikeRNConnectionAPIv3.js +113 -3
- package/lib/commonjs/v3/SpikeRNConnectionAPIv3.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/v3/RecordConfig.js +11 -0
- package/lib/module/v3/RecordConfig.js.map +1 -0
- package/lib/module/v3/SpikeRNConnectionAPIv3.js +113 -3
- package/lib/module/v3/SpikeRNConnectionAPIv3.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/v3/RecordConfig.d.ts +8 -0
- package/lib/typescript/v3/RecordConfig.d.ts.map +1 -0
- package/lib/typescript/v3/SpikeRNConnectionAPIv3.d.ts +99 -1
- package/lib/typescript/v3/SpikeRNConnectionAPIv3.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -0
- package/src/v3/RecordConfig.ts +13 -0
- package/src/v3/SpikeRNConnectionAPIv3.ts +189 -3
- package/src/version.ts +1 -1
|
@@ -7,6 +7,7 @@ import type { SpikeRecord } from "./DataModels/SpikeRecord";
|
|
|
7
7
|
import { HealthConnectAvailabilityStatus } from "./DataModels/HealthConnectAvailabilityStatus";
|
|
8
8
|
import type { ActivityConfig } from "./DataModels/ActivityConfig";
|
|
9
9
|
import type { SleepConfig } from "./DataModels/SleepConfig";
|
|
10
|
+
import type { RecordConfig } from "./RecordConfig";
|
|
10
11
|
import type { UserInfoResponse } from "./DataModels/UserInfoResponse";
|
|
11
12
|
import type { Provider } from "./DataModels/Provider";
|
|
12
13
|
import type { UserProperties } from "./DataModels/UserProperties";
|
|
@@ -92,7 +93,7 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
92
93
|
*
|
|
93
94
|
* @category Data reading
|
|
94
95
|
*/
|
|
95
|
-
getRecords({ ofTypes, from, to, filter }: {
|
|
96
|
+
getRecords({ ofTypes, from, to, filter, config }: {
|
|
96
97
|
/** Array of metric types to retrieve (e.g., heart rate, steps, sleep) */
|
|
97
98
|
ofTypes: MetricType[];
|
|
98
99
|
/** Start datetime for the data range (inclusive) */
|
|
@@ -101,6 +102,8 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
101
102
|
to: Date;
|
|
102
103
|
/** Optional filter to apply to the results (can filter by provider, etc.) */
|
|
103
104
|
filter?: StatisticsFilter | null;
|
|
105
|
+
/** Optional configuration for records queries (e.g., include samples) */
|
|
106
|
+
config?: RecordConfig | null;
|
|
104
107
|
}): Promise<SpikeRecord[]>;
|
|
105
108
|
/**
|
|
106
109
|
* Retrieves all activities based on the specified configuration.
|
|
@@ -235,6 +238,30 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
235
238
|
*/
|
|
236
239
|
sleepConfigs?: SleepConfig[];
|
|
237
240
|
}): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Triggers a backfill of health data for the specified number of days.
|
|
243
|
+
*
|
|
244
|
+
* This method pushes historical health data to the Spike backend. It requires that
|
|
245
|
+
* health permissions have already been granted (via `requestHealthPermissions` on iOS
|
|
246
|
+
* or Health Connect / Samsung Health Data integration on Android).
|
|
247
|
+
*
|
|
248
|
+
* The number of days to backfill configured in the Spike dashboard will be used if
|
|
249
|
+
* `days` is not provided.
|
|
250
|
+
*
|
|
251
|
+
* @category Backfill
|
|
252
|
+
*/
|
|
253
|
+
backfill({ days, statisticTypes, metricTypes, activityConfigs, sleepConfigs }: {
|
|
254
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
255
|
+
days?: number;
|
|
256
|
+
/** Array of statistic types to backfill. */
|
|
257
|
+
statisticTypes?: StatisticsType[];
|
|
258
|
+
/** Array of metric types to backfill. */
|
|
259
|
+
metricTypes?: MetricType[];
|
|
260
|
+
/** Array of activity configuration objects to backfill. */
|
|
261
|
+
activityConfigs?: ActivityConfig[];
|
|
262
|
+
/** Array of sleep configuration objects to backfill. */
|
|
263
|
+
sleepConfigs?: SleepConfig[];
|
|
264
|
+
}): Promise<void>;
|
|
238
265
|
/**
|
|
239
266
|
* Disables background checks for new data.
|
|
240
267
|
*
|
|
@@ -263,6 +290,27 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
263
290
|
* @category iOS HealthKit
|
|
264
291
|
*/
|
|
265
292
|
isHealthKitIntegrationEnabled(): Promise<boolean>;
|
|
293
|
+
/**
|
|
294
|
+
* Requests HealthKit read permissions for the given categories, then starts a backfill.
|
|
295
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
296
|
+
*
|
|
297
|
+
* For manual control over backfill, use {@link requestHealthPermissions} and {@link backfill} instead.
|
|
298
|
+
*
|
|
299
|
+
* @category iOS HealthKit
|
|
300
|
+
* @category Backfill
|
|
301
|
+
*/
|
|
302
|
+
requestPermissionsFromHealthKitAndBackfill({ days, statisticTypes, metricTypes, activityConfigs, sleepConfigs }: {
|
|
303
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
304
|
+
days?: number;
|
|
305
|
+
/** Array of statistic types. */
|
|
306
|
+
statisticTypes?: StatisticsType[];
|
|
307
|
+
/** Array of metric types. */
|
|
308
|
+
metricTypes?: MetricType[];
|
|
309
|
+
/** Array of activity configuration objects. */
|
|
310
|
+
activityConfigs?: ActivityConfig[];
|
|
311
|
+
/** Array of sleep configuration objects. */
|
|
312
|
+
sleepConfigs?: SleepConfig[];
|
|
313
|
+
}): Promise<void>;
|
|
266
314
|
/**
|
|
267
315
|
* Check if Health Connect is installed or should be updated.
|
|
268
316
|
*
|
|
@@ -349,6 +397,35 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
349
397
|
* @returns true if the feature is available, false otherwise
|
|
350
398
|
*/
|
|
351
399
|
isHealthConnectFeatureAvailable(feature: HealthConnectFeature): Promise<boolean>;
|
|
400
|
+
/**
|
|
401
|
+
* Enables Health Connect integration, requests permissions for the given categories, then starts a backfill.
|
|
402
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
403
|
+
*
|
|
404
|
+
* This mirrors the native {@link requestSamsungPermissionsAndBackfill} flow: enable integration,
|
|
405
|
+
* request permissions, then run backfill (implemented by composing existing Health Connect APIs).
|
|
406
|
+
*
|
|
407
|
+
* For manual control, use {@link enableHealthConnectIntegration}, {@link getHealthConnectPermissions},
|
|
408
|
+
* {@link requestPermissionsFromHealthConnect}, and {@link backfill} instead.
|
|
409
|
+
*
|
|
410
|
+
* @category Android Health Connect
|
|
411
|
+
* @category Backfill
|
|
412
|
+
*/
|
|
413
|
+
requestHealthConnectPermissionsAndBackfill({ days, statisticTypes, metricTypes, activityConfigs, sleepConfigs, includeEnhancedPermissions, includeBackgroundDelivery, }: {
|
|
414
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
415
|
+
days?: number;
|
|
416
|
+
/** Array of statistic types. */
|
|
417
|
+
statisticTypes?: StatisticsType[];
|
|
418
|
+
/** Array of metric types. */
|
|
419
|
+
metricTypes?: MetricType[];
|
|
420
|
+
/** Array of activity configuration objects. */
|
|
421
|
+
activityConfigs?: ActivityConfig[];
|
|
422
|
+
/** Array of sleep configuration objects. */
|
|
423
|
+
sleepConfigs?: SleepConfig[];
|
|
424
|
+
/** Whether to include enhanced permissions (e.g. background read). Defaults to false. */
|
|
425
|
+
includeEnhancedPermissions?: boolean;
|
|
426
|
+
/** Whether to include background delivery permissions. Defaults to false. */
|
|
427
|
+
includeBackgroundDelivery?: boolean;
|
|
428
|
+
}): Promise<void>;
|
|
352
429
|
/**
|
|
353
430
|
* Check if Samsung Health Data is available on the device.
|
|
354
431
|
*
|
|
@@ -408,6 +485,27 @@ export declare class SpikeRNConnectionAPIv3 {
|
|
|
408
485
|
* @category Permissions
|
|
409
486
|
*/
|
|
410
487
|
requestPermissionsFromSamsungHealthData({ statisticTypes, metricTypes, activityConfigs, sleepConfigs }: GetHealthConnectPermissionsParameters): Promise<string[]>;
|
|
488
|
+
/**
|
|
489
|
+
* Enables Samsung Health Data integration, requests permissions for the given categories, then starts a backfill.
|
|
490
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
491
|
+
*
|
|
492
|
+
* For manual control, use {@link enableSamsungHealthDataIntegration}, {@link requestPermissionsFromSamsungHealthData}, and {@link backfill} instead.
|
|
493
|
+
*
|
|
494
|
+
* @category Samsung Health Data
|
|
495
|
+
* @category Backfill
|
|
496
|
+
*/
|
|
497
|
+
requestSamsungPermissionsAndBackfill({ days, statisticTypes, metricTypes, activityConfigs, sleepConfigs }: {
|
|
498
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
499
|
+
days?: number;
|
|
500
|
+
/** Array of statistic types. */
|
|
501
|
+
statisticTypes?: StatisticsType[];
|
|
502
|
+
/** Array of metric types. */
|
|
503
|
+
metricTypes?: MetricType[];
|
|
504
|
+
/** Array of activity configuration objects. */
|
|
505
|
+
activityConfigs?: ActivityConfig[];
|
|
506
|
+
/** Array of sleep configuration objects. */
|
|
507
|
+
sleepConfigs?: SleepConfig[];
|
|
508
|
+
}): Promise<void>;
|
|
411
509
|
/**
|
|
412
510
|
* Analyze the nutritional content of food on a given image.
|
|
413
511
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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,OAAO,CAAC,IAAI,CAAC;IASjB;;;;;;;OAOG;IACG,gCAAgC,CAAC,EACnC,EAAE,EACF,WAAW,EACd,EAAE;QACC,iDAAiD;QACjD,EAAE,EAAE,MAAM,CAAC;QACX,iCAAiC;QACjC,WAAW,EAAE,MAAM,CAAA;KACtB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAc1C;;;;;;;OAOG;IACG,4BAA4B,CAAC,EAC/B,WAAW,EACX,MAAkB,EACrB,EAAE;QACC,6DAA6D;QAC7D,WAAW,EAAE,MAAM,CAAC;QACpB,yFAAyF;QACzF,MAAM,CAAC,EAAE,oCAAoC,CAAA;KAChD,GAAG,OAAO,CAAC,oCAAoC,CAAC;IAcjD;;;;;;;;;OASG;IACG,qBAAqB,CAAC,EACxB,eAAe,EAClB,EAAE;QACC,qCAAqC;QACrC,eAAe,EAAE,eAAe,CAAA;KACnC,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAa1C;;;;;;;OAOG;IACG,sBAAsB,CAAC,EACzB,eAAe,EAClB,EAAE;QACC,uFAAuF;QACvF,eAAe,EAAE,eAAe,CAAA;KACnC,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAa7C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SPIKE_SDK_VERSION = "4.
|
|
1
|
+
export declare const SPIKE_SDK_VERSION = "4.5.23-beta.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-spike-sdk",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"iosVersion": "4.
|
|
3
|
+
"version": "4.5.23-beta.1",
|
|
4
|
+
"iosVersion": "4.5.21-beta.1",
|
|
5
5
|
"description": "Spike API for health and productivity data from wearables and IoT devices",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
7
7
|
"module": "lib/module/index",
|
package/src/index.ts
CHANGED
|
@@ -108,6 +108,7 @@ import type { ActivityEntry } from './v3/DataModels/ActivityEntry';
|
|
|
108
108
|
import type { ActivitySamples } from './v3/DataModels/ActivitySamples';
|
|
109
109
|
import type { RecordSource } from './v3/DataModels/RecordSource';
|
|
110
110
|
import { SleepConfig, SleepConfigConstructorInterface } from './v3/DataModels/SleepConfig';
|
|
111
|
+
import { RecordConfig, RecordConfigConstructorParameters } from './v3/RecordConfig';
|
|
111
112
|
import type { SpikeRecord } from './v3/DataModels/SpikeRecord';
|
|
112
113
|
import type { Statistic } from './v3/DataModels/Statistic';
|
|
113
114
|
import type { UUID } from './v3/DataModels/UUID';
|
|
@@ -153,6 +154,7 @@ export {
|
|
|
153
154
|
MetricType,
|
|
154
155
|
Provider,
|
|
155
156
|
ProviderSource,
|
|
157
|
+
RecordConfig,
|
|
156
158
|
RecordSource,
|
|
157
159
|
SleepConfig,
|
|
158
160
|
SpikeRecord,
|
|
@@ -178,6 +180,7 @@ export type {
|
|
|
178
180
|
StatisticsFilterConstructorParameters,
|
|
179
181
|
ActivityConfigConstructorInterface,
|
|
180
182
|
SleepConfigConstructorInterface,
|
|
183
|
+
RecordConfigConstructorParameters,
|
|
181
184
|
BackgroundDeliveryConfig,
|
|
182
185
|
SamsungHealthDataAvailability,
|
|
183
186
|
IntegrationInitConfig,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RecordConfigConstructorParameters {
|
|
2
|
+
includeSamples?: boolean,
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class RecordConfig {
|
|
6
|
+
includeSamples: boolean = false
|
|
7
|
+
|
|
8
|
+
constructor({
|
|
9
|
+
includeSamples = false,
|
|
10
|
+
}: RecordConfigConstructorParameters) {
|
|
11
|
+
this.includeSamples = includeSamples;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -11,6 +11,7 @@ import type { SpikeRecord } from "./DataModels/SpikeRecord";
|
|
|
11
11
|
import { HealthConnectAvailabilityStatus } from "./DataModels/HealthConnectAvailabilityStatus";
|
|
12
12
|
import type { ActivityConfig } from "./DataModels/ActivityConfig";
|
|
13
13
|
import type { SleepConfig } from "./DataModels/SleepConfig";
|
|
14
|
+
import type { RecordConfig } from "./RecordConfig";
|
|
14
15
|
import type { UserInfoResponse } from "./DataModels/UserInfoResponse";
|
|
15
16
|
import type { Provider } from "./DataModels/Provider";
|
|
16
17
|
import type { UserProperties } from "./DataModels/UserProperties";
|
|
@@ -165,7 +166,8 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
165
166
|
ofTypes,
|
|
166
167
|
from,
|
|
167
168
|
to,
|
|
168
|
-
filter = null
|
|
169
|
+
filter = null,
|
|
170
|
+
config = null
|
|
169
171
|
} : {
|
|
170
172
|
/** Array of metric types to retrieve (e.g., heart rate, steps, sleep) */
|
|
171
173
|
ofTypes: MetricType[],
|
|
@@ -178,17 +180,20 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
178
180
|
|
|
179
181
|
/** Optional filter to apply to the results (can filter by provider, etc.) */
|
|
180
182
|
filter?: StatisticsFilter | null,
|
|
183
|
+
|
|
184
|
+
/** Optional configuration for records queries (e.g., include samples) */
|
|
185
|
+
config?: RecordConfig | null,
|
|
181
186
|
}): Promise<SpikeRecord[]> {
|
|
182
187
|
if (!SpikeSdk) throw new SpikeException();
|
|
183
188
|
|
|
184
189
|
const stringTypes = ofTypes.map ( (item: MetricType) => item )
|
|
185
|
-
// console.log("Record types requested", stringTypes)
|
|
186
190
|
const result = await SpikeSdk.getRecords(
|
|
187
191
|
this.connectionUUID,
|
|
188
192
|
stringTypes,
|
|
189
193
|
from.toISOString(),
|
|
190
194
|
to.toISOString(),
|
|
191
|
-
!!filter ? JSON.stringify(filter) : null
|
|
195
|
+
!!filter ? JSON.stringify(filter) : null,
|
|
196
|
+
config ? JSON.stringify(camelToSnake(config)) : null
|
|
192
197
|
)
|
|
193
198
|
const jsonResult = JSON.parse(result)
|
|
194
199
|
const finalResult = snakeToCamel(jsonResult) as [SpikeRecord]
|
|
@@ -445,6 +450,48 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
445
450
|
}
|
|
446
451
|
}
|
|
447
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Triggers a backfill of health data for the specified number of days.
|
|
455
|
+
*
|
|
456
|
+
* This method pushes historical health data to the Spike backend. It requires that
|
|
457
|
+
* health permissions have already been granted (via `requestHealthPermissions` on iOS
|
|
458
|
+
* or Health Connect / Samsung Health Data integration on Android).
|
|
459
|
+
*
|
|
460
|
+
* The number of days to backfill configured in the Spike dashboard will be used if
|
|
461
|
+
* `days` is not provided.
|
|
462
|
+
*
|
|
463
|
+
* @category Backfill
|
|
464
|
+
*/
|
|
465
|
+
async backfill({
|
|
466
|
+
days = undefined,
|
|
467
|
+
statisticTypes = [],
|
|
468
|
+
metricTypes = [],
|
|
469
|
+
activityConfigs = [],
|
|
470
|
+
sleepConfigs = []
|
|
471
|
+
}: {
|
|
472
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
473
|
+
days?: number,
|
|
474
|
+
/** Array of statistic types to backfill. */
|
|
475
|
+
statisticTypes?: StatisticsType[],
|
|
476
|
+
/** Array of metric types to backfill. */
|
|
477
|
+
metricTypes?: MetricType[],
|
|
478
|
+
/** Array of activity configuration objects to backfill. */
|
|
479
|
+
activityConfigs?: ActivityConfig[],
|
|
480
|
+
/** Array of sleep configuration objects to backfill. */
|
|
481
|
+
sleepConfigs?: SleepConfig[],
|
|
482
|
+
}): Promise<void> {
|
|
483
|
+
if (!SpikeSdk) throw new SpikeException();
|
|
484
|
+
|
|
485
|
+
await SpikeSdk.backfill(
|
|
486
|
+
this.connectionUUID,
|
|
487
|
+
days !== undefined ? String(days) : null,
|
|
488
|
+
statisticTypes,
|
|
489
|
+
metricTypes,
|
|
490
|
+
activityConfigs.map((object) => JSON.stringify(object)),
|
|
491
|
+
sleepConfigs.map((object) => JSON.stringify(object))
|
|
492
|
+
)
|
|
493
|
+
}
|
|
494
|
+
|
|
448
495
|
/**
|
|
449
496
|
* Disables background checks for new data.
|
|
450
497
|
*
|
|
@@ -510,6 +557,46 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
510
557
|
return await SpikeSdk.isHealthKitIntegrationEnabled(this.connectionUUID)
|
|
511
558
|
}
|
|
512
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Requests HealthKit read permissions for the given categories, then starts a backfill.
|
|
562
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
563
|
+
*
|
|
564
|
+
* For manual control over backfill, use {@link requestHealthPermissions} and {@link backfill} instead.
|
|
565
|
+
*
|
|
566
|
+
* @category iOS HealthKit
|
|
567
|
+
* @category Backfill
|
|
568
|
+
*/
|
|
569
|
+
async requestPermissionsFromHealthKitAndBackfill({
|
|
570
|
+
days = undefined,
|
|
571
|
+
statisticTypes = [],
|
|
572
|
+
metricTypes = [],
|
|
573
|
+
activityConfigs = [],
|
|
574
|
+
sleepConfigs = []
|
|
575
|
+
}: {
|
|
576
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
577
|
+
days?: number,
|
|
578
|
+
/** Array of statistic types. */
|
|
579
|
+
statisticTypes?: StatisticsType[],
|
|
580
|
+
/** Array of metric types. */
|
|
581
|
+
metricTypes?: MetricType[],
|
|
582
|
+
/** Array of activity configuration objects. */
|
|
583
|
+
activityConfigs?: ActivityConfig[],
|
|
584
|
+
/** Array of sleep configuration objects. */
|
|
585
|
+
sleepConfigs?: SleepConfig[],
|
|
586
|
+
}): Promise<void> {
|
|
587
|
+
if (Platform.OS !== 'ios') return;
|
|
588
|
+
if (!SpikeSdk) throw new SpikeException();
|
|
589
|
+
|
|
590
|
+
await SpikeSdk.requestPermissionsFromHealthKitAndBackfill(
|
|
591
|
+
this.connectionUUID,
|
|
592
|
+
statisticTypes,
|
|
593
|
+
metricTypes,
|
|
594
|
+
activityConfigs.map((object) => JSON.stringify(object)),
|
|
595
|
+
sleepConfigs.map((object) => JSON.stringify(object)),
|
|
596
|
+
days !== undefined ? String(days) : null
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
|
|
513
600
|
// ------------------------- Android specific Health Connect permissions -------------------------
|
|
514
601
|
|
|
515
602
|
/**
|
|
@@ -678,6 +765,65 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
678
765
|
return await SpikeSdk.isHealthConnectFeatureAvailable(this.connectionUUID, feature)
|
|
679
766
|
}
|
|
680
767
|
|
|
768
|
+
/**
|
|
769
|
+
* Enables Health Connect integration, requests permissions for the given categories, then starts a backfill.
|
|
770
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
771
|
+
*
|
|
772
|
+
* This mirrors the native {@link requestSamsungPermissionsAndBackfill} flow: enable integration,
|
|
773
|
+
* request permissions, then run backfill (implemented by composing existing Health Connect APIs).
|
|
774
|
+
*
|
|
775
|
+
* For manual control, use {@link enableHealthConnectIntegration}, {@link getHealthConnectPermissions},
|
|
776
|
+
* {@link requestPermissionsFromHealthConnect}, and {@link backfill} instead.
|
|
777
|
+
*
|
|
778
|
+
* @category Android Health Connect
|
|
779
|
+
* @category Backfill
|
|
780
|
+
*/
|
|
781
|
+
async requestHealthConnectPermissionsAndBackfill({
|
|
782
|
+
days = undefined,
|
|
783
|
+
statisticTypes = [],
|
|
784
|
+
metricTypes = [],
|
|
785
|
+
activityConfigs = [],
|
|
786
|
+
sleepConfigs = [],
|
|
787
|
+
includeEnhancedPermissions = false,
|
|
788
|
+
includeBackgroundDelivery = false,
|
|
789
|
+
}: {
|
|
790
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
791
|
+
days?: number,
|
|
792
|
+
/** Array of statistic types. */
|
|
793
|
+
statisticTypes?: StatisticsType[],
|
|
794
|
+
/** Array of metric types. */
|
|
795
|
+
metricTypes?: MetricType[],
|
|
796
|
+
/** Array of activity configuration objects. */
|
|
797
|
+
activityConfigs?: ActivityConfig[],
|
|
798
|
+
/** Array of sleep configuration objects. */
|
|
799
|
+
sleepConfigs?: SleepConfig[],
|
|
800
|
+
/** Whether to include enhanced permissions (e.g. background read). Defaults to false. */
|
|
801
|
+
includeEnhancedPermissions?: boolean,
|
|
802
|
+
/** Whether to include background delivery permissions. Defaults to false. */
|
|
803
|
+
includeBackgroundDelivery?: boolean,
|
|
804
|
+
}): Promise<void> {
|
|
805
|
+
if (Platform.OS !== 'android') return;
|
|
806
|
+
if (!SpikeSdk) throw new SpikeException();
|
|
807
|
+
|
|
808
|
+
await this.enableHealthConnectIntegration();
|
|
809
|
+
const permissions = await this.getHealthConnectPermissions({
|
|
810
|
+
statisticTypes,
|
|
811
|
+
metricTypes,
|
|
812
|
+
activityConfigs,
|
|
813
|
+
sleepConfigs,
|
|
814
|
+
includeEnhancedPermissions,
|
|
815
|
+
includeBackgroundDelivery,
|
|
816
|
+
});
|
|
817
|
+
await this.requestPermissionsFromHealthConnect({ permissions });
|
|
818
|
+
await this.backfill({
|
|
819
|
+
days,
|
|
820
|
+
statisticTypes,
|
|
821
|
+
metricTypes,
|
|
822
|
+
activityConfigs,
|
|
823
|
+
sleepConfigs,
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
|
|
681
827
|
// ------------------------- Samsung Health Data permissions -------------------------
|
|
682
828
|
|
|
683
829
|
/**
|
|
@@ -806,6 +952,46 @@ export class SpikeRNConnectionAPIv3 {
|
|
|
806
952
|
)
|
|
807
953
|
}
|
|
808
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Enables Samsung Health Data integration, requests permissions for the given categories, then starts a backfill.
|
|
957
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
958
|
+
*
|
|
959
|
+
* For manual control, use {@link enableSamsungHealthDataIntegration}, {@link requestPermissionsFromSamsungHealthData}, and {@link backfill} instead.
|
|
960
|
+
*
|
|
961
|
+
* @category Samsung Health Data
|
|
962
|
+
* @category Backfill
|
|
963
|
+
*/
|
|
964
|
+
async requestSamsungPermissionsAndBackfill({
|
|
965
|
+
days = undefined,
|
|
966
|
+
statisticTypes = [],
|
|
967
|
+
metricTypes = [],
|
|
968
|
+
activityConfigs = [],
|
|
969
|
+
sleepConfigs = []
|
|
970
|
+
}: {
|
|
971
|
+
/** Number of days to backfill. If not provided, uses the value from Spike dashboard config. */
|
|
972
|
+
days?: number,
|
|
973
|
+
/** Array of statistic types. */
|
|
974
|
+
statisticTypes?: StatisticsType[],
|
|
975
|
+
/** Array of metric types. */
|
|
976
|
+
metricTypes?: MetricType[],
|
|
977
|
+
/** Array of activity configuration objects. */
|
|
978
|
+
activityConfigs?: ActivityConfig[],
|
|
979
|
+
/** Array of sleep configuration objects. */
|
|
980
|
+
sleepConfigs?: SleepConfig[],
|
|
981
|
+
}): Promise<void> {
|
|
982
|
+
if (Platform.OS !== 'android') return;
|
|
983
|
+
if (!SpikeSdk) throw new SpikeException();
|
|
984
|
+
|
|
985
|
+
await SpikeSdk.requestSamsungPermissionsAndBackfill(
|
|
986
|
+
this.connectionUUID,
|
|
987
|
+
statisticTypes,
|
|
988
|
+
metricTypes,
|
|
989
|
+
activityConfigs.map((object) => JSON.stringify(object)),
|
|
990
|
+
sleepConfigs.map((object) => JSON.stringify(object)),
|
|
991
|
+
days !== undefined ? String(days) : null
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
|
|
809
995
|
// ------------------------- Nutrition AI -------------------------
|
|
810
996
|
|
|
811
997
|
/**
|
package/src/version.ts
CHANGED