react-native-spike-sdk 4.6.13 → 4.7.13
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 +1 -1
- package/android/src/main/java/com/spikesdk/SpikeMappers.kt +0 -46
- package/android/src/main/java/com/spikesdk/SpikeSdkModule.kt +1 -476
- package/ios/SpikeExceptionMapper.swift +4 -12
- package/ios/SpikeSdk.m +0 -79
- package/ios/SpikeSdk.swift +7 -417
- package/lib/commonjs/Spike.js +1 -57
- package/lib/commonjs/Spike.js.map +1 -1
- package/lib/commonjs/SpikeException.js +15 -94
- package/lib/commonjs/SpikeException.js.map +1 -1
- package/lib/commonjs/index.js +0 -71
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Spike.js +1 -55
- package/lib/module/Spike.js.map +1 -1
- package/lib/module/SpikeException.js +14 -83
- package/lib/module/SpikeException.js.map +1 -1
- package/lib/module/index.js +3 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/Spike.d.ts +2 -29
- package/lib/typescript/Spike.d.ts.map +1 -1
- package/lib/typescript/SpikeException.d.ts +5 -30
- package/lib/typescript/SpikeException.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -24
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/Spike.ts +4 -89
- package/src/SpikeException.ts +13 -96
- package/src/index.ts +0 -61
- package/src/version.ts +1 -1
- package/android/src/main/java/com/spikesdk/SpikeConnectionLogger.kt +0 -37
- package/ios/SpikeConnectionListener.swift +0 -17
- package/ios/SpikeConnectionLogger.swift +0 -43
- package/ios/SpikeDataTypeMapper.swift +0 -255
- package/lib/commonjs/DataModels/SpikeActivitiesStreamDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeActivitiesStreamDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeActivitiesSummaryDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeActivitiesSummaryDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeBodyDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeBodyDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeBreathingDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeBreathingDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeCaloriesDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeCaloriesDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeData.js +0 -6
- package/lib/commonjs/DataModels/SpikeData.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeDataTypes.js +0 -23
- package/lib/commonjs/DataModels/SpikeDataTypes.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeDistanceDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeDistanceDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeEcgDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeEcgDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeGlucoseDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeGlucoseDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeHeartDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeHeartDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeOxygenSaturationDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeOxygenSaturationDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeSleepDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeSleepDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeStepsDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeStepsDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeStepsIntradayDataEntry.js +0 -2
- package/lib/commonjs/DataModels/SpikeStepsIntradayDataEntry.js.map +0 -1
- package/lib/commonjs/DataModels/SpikeWebhookJob.js +0 -2
- package/lib/commonjs/DataModels/SpikeWebhookJob.js.map +0 -1
- package/lib/commonjs/DataTypes/SpikeDataType.js +0 -59
- package/lib/commonjs/DataTypes/SpikeDataType.js.map +0 -1
- package/lib/commonjs/SpikeBackgroundDeliveriesLogger.js +0 -2
- package/lib/commonjs/SpikeBackgroundDeliveriesLogger.js.map +0 -1
- package/lib/commonjs/SpikeConnection.js +0 -301
- package/lib/commonjs/SpikeConnection.js.map +0 -1
- package/lib/commonjs/SpikeConnectionTypes.js +0 -6
- package/lib/commonjs/SpikeConnectionTypes.js.map +0 -1
- package/lib/commonjs/SpikeLogger.js +0 -6
- package/lib/commonjs/SpikeLogger.js.map +0 -1
- package/lib/module/DataModels/SpikeActivitiesStreamDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeActivitiesStreamDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeActivitiesSummaryDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeActivitiesSummaryDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeBodyDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeBodyDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeBreathingDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeBreathingDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeCaloriesDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeCaloriesDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeData.js +0 -4
- package/lib/module/DataModels/SpikeData.js.map +0 -1
- package/lib/module/DataModels/SpikeDataTypes.js +0 -19
- package/lib/module/DataModels/SpikeDataTypes.js.map +0 -1
- package/lib/module/DataModels/SpikeDistanceDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeDistanceDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeEcgDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeEcgDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeGlucoseDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeGlucoseDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeHeartDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeHeartDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeOxygenSaturationDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeOxygenSaturationDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeSleepDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeSleepDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeStepsDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeStepsDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeStepsIntradayDataEntry.js +0 -2
- package/lib/module/DataModels/SpikeStepsIntradayDataEntry.js.map +0 -1
- package/lib/module/DataModels/SpikeWebhookJob.js +0 -2
- package/lib/module/DataModels/SpikeWebhookJob.js.map +0 -1
- package/lib/module/DataTypes/SpikeDataType.js +0 -42
- package/lib/module/DataTypes/SpikeDataType.js.map +0 -1
- package/lib/module/SpikeBackgroundDeliveriesLogger.js +0 -2
- package/lib/module/SpikeBackgroundDeliveriesLogger.js.map +0 -1
- package/lib/module/SpikeConnection.js +0 -296
- package/lib/module/SpikeConnection.js.map +0 -1
- package/lib/module/SpikeConnectionTypes.js +0 -4
- package/lib/module/SpikeConnectionTypes.js.map +0 -1
- package/lib/module/SpikeLogger.js +0 -4
- package/lib/module/SpikeLogger.js.map +0 -1
- package/lib/typescript/DataModels/SpikeActivitiesStreamDataEntry.d.ts +0 -66
- package/lib/typescript/DataModels/SpikeActivitiesStreamDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeActivitiesSummaryDataEntry.d.ts +0 -29
- package/lib/typescript/DataModels/SpikeActivitiesSummaryDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeBodyDataEntry.d.ts +0 -54
- package/lib/typescript/DataModels/SpikeBodyDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeBreathingDataEntry.d.ts +0 -13
- package/lib/typescript/DataModels/SpikeBreathingDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeCaloriesDataEntry.d.ts +0 -15
- package/lib/typescript/DataModels/SpikeCaloriesDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeData.d.ts +0 -27
- package/lib/typescript/DataModels/SpikeData.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeDataTypes.d.ts +0 -17
- package/lib/typescript/DataModels/SpikeDataTypes.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeDistanceDataEntry.d.ts +0 -13
- package/lib/typescript/DataModels/SpikeDistanceDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeEcgDataEntry.d.ts +0 -13
- package/lib/typescript/DataModels/SpikeEcgDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeGlucoseDataEntry.d.ts +0 -21
- package/lib/typescript/DataModels/SpikeGlucoseDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeHeartDataEntry.d.ts +0 -32
- package/lib/typescript/DataModels/SpikeHeartDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeOxygenSaturationDataEntry.d.ts +0 -15
- package/lib/typescript/DataModels/SpikeOxygenSaturationDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeSleepDataEntry.d.ts +0 -30
- package/lib/typescript/DataModels/SpikeSleepDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeStepsDataEntry.d.ts +0 -13
- package/lib/typescript/DataModels/SpikeStepsDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeStepsIntradayDataEntry.d.ts +0 -17
- package/lib/typescript/DataModels/SpikeStepsIntradayDataEntry.d.ts.map +0 -1
- package/lib/typescript/DataModels/SpikeWebhookJob.d.ts +0 -11
- package/lib/typescript/DataModels/SpikeWebhookJob.d.ts.map +0 -1
- package/lib/typescript/DataTypes/SpikeDataType.d.ts +0 -68
- package/lib/typescript/DataTypes/SpikeDataType.d.ts.map +0 -1
- package/lib/typescript/SpikeBackgroundDeliveriesLogger.d.ts +0 -4
- package/lib/typescript/SpikeBackgroundDeliveriesLogger.d.ts.map +0 -1
- package/lib/typescript/SpikeConnection.d.ts +0 -63
- package/lib/typescript/SpikeConnection.d.ts.map +0 -1
- package/lib/typescript/SpikeConnectionTypes.d.ts +0 -102
- package/lib/typescript/SpikeConnectionTypes.d.ts.map +0 -1
- package/lib/typescript/SpikeLogger.d.ts +0 -13
- package/lib/typescript/SpikeLogger.d.ts.map +0 -1
- package/src/DataModels/SpikeActivitiesStreamDataEntry.ts +0 -67
- package/src/DataModels/SpikeActivitiesSummaryDataEntry.ts +0 -28
- package/src/DataModels/SpikeBodyDataEntry.ts +0 -61
- package/src/DataModels/SpikeBreathingDataEntry.ts +0 -12
- package/src/DataModels/SpikeCaloriesDataEntry.ts +0 -13
- package/src/DataModels/SpikeData.ts +0 -38
- package/src/DataModels/SpikeDataTypes.ts +0 -31
- package/src/DataModels/SpikeDistanceDataEntry.ts +0 -12
- package/src/DataModels/SpikeEcgDataEntry.ts +0 -12
- package/src/DataModels/SpikeGlucoseDataEntry.ts +0 -20
- package/src/DataModels/SpikeHeartDataEntry.ts +0 -34
- package/src/DataModels/SpikeOxygenSaturationDataEntry.ts +0 -14
- package/src/DataModels/SpikeSleepDataEntry.ts +0 -29
- package/src/DataModels/SpikeStepsDataEntry.ts +0 -12
- package/src/DataModels/SpikeStepsIntradayDataEntry.ts +0 -16
- package/src/DataModels/SpikeWebhookJob.ts +0 -10
- package/src/DataTypes/SpikeDataType.ts +0 -93
- package/src/SpikeBackgroundDeliveriesLogger.ts +0 -3
- package/src/SpikeConnection.ts +0 -495
- package/src/SpikeConnectionTypes.ts +0 -124
- package/src/SpikeLogger.ts +0 -14
package/ios/SpikeSdk.m
CHANGED
|
@@ -5,86 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
// MARK: Spike SDK level
|
|
7
7
|
|
|
8
|
-
RCT_EXTERN_METHOD(createConnection: (NSString)uuid
|
|
9
|
-
withAppId: (NSString)appId
|
|
10
|
-
withAuthToken: (NSString)authToken
|
|
11
|
-
withCustomerEndUserId: (NSString)customerEndUserId
|
|
12
|
-
withCallbackUrl: (NSString)callbackUrl
|
|
13
|
-
withUseLogger: (BOOL)useLogger
|
|
14
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
15
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
16
|
-
|
|
17
|
-
RCT_EXTERN_METHOD(getBackgroundConnections: (RCTPromiseResolveBlock)resolve
|
|
18
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
19
|
-
|
|
20
|
-
RCT_EXTERN_METHOD(ensurePermissionsAreGranted: (NSArray<NSString>)permissions
|
|
21
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
22
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
23
|
-
|
|
24
8
|
RCT_EXTERN_METHOD(isHealthDataAvailable: (RCTPromiseResolveBlock)resolve
|
|
25
9
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
26
10
|
|
|
27
|
-
// MARK: SpikeConnection level
|
|
28
|
-
|
|
29
|
-
RCT_EXTERN_METHOD(getAppId: (NSString)connectionUUID
|
|
30
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
31
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
32
|
-
|
|
33
|
-
RCT_EXTERN_METHOD(getSpikeEndUserId: (NSString)connectionUUID
|
|
34
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
35
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
36
|
-
|
|
37
|
-
RCT_EXTERN_METHOD(getCustomerEndUserId: (NSString)connectionUUID
|
|
38
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
39
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
40
|
-
|
|
41
|
-
RCT_EXTERN_METHOD(close: (NSString)connectionUUID
|
|
42
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
43
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
44
|
-
|
|
45
|
-
RCT_EXTERN_METHOD(extractData: (NSString)connectionUUID
|
|
46
|
-
withDataType: (NSString)dataType
|
|
47
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
48
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
49
|
-
|
|
50
|
-
RCT_EXTERN_METHOD(extractDataInRange: (NSString)connectionUUID
|
|
51
|
-
withDataType: (NSString)dataType
|
|
52
|
-
withFromDateMillis: (double)fromDateMillis
|
|
53
|
-
withToDateMillis: (double)toDateMillis
|
|
54
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
55
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
56
|
-
|
|
57
|
-
// MARK: SpikeWebhookConnection level
|
|
58
|
-
|
|
59
|
-
RCT_EXTERN_METHOD(getCallbackUrl: (NSString)connectionUUID
|
|
60
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
61
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
62
|
-
|
|
63
|
-
RCT_EXTERN_METHOD(extractAndPostData: (NSString)connectionUUID
|
|
64
|
-
withDataType: (NSString)dataType
|
|
65
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
66
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
67
|
-
|
|
68
|
-
RCT_EXTERN_METHOD(extractAndPostDataInRange: (NSString)connectionUUID
|
|
69
|
-
withDataType: (NSString)dataType
|
|
70
|
-
withFromDateMillis: (double)fromDateMillis
|
|
71
|
-
withToDateMillis: (double)toDateMillis
|
|
72
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
73
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
74
|
-
|
|
75
|
-
RCT_EXTERN_METHOD(enableBackgroundDelivery: (NSString)connectionUUID
|
|
76
|
-
withDataTypes: (NSArray<NSString>)dataTypes
|
|
77
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
78
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
79
|
-
|
|
80
|
-
RCT_EXTERN_METHOD(getBackgroundDeliveryDataTypes: (NSString)connectionUUID
|
|
81
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
82
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
83
|
-
|
|
84
|
-
RCT_EXTERN_METHOD(setListener: (NSString)connectionUUID
|
|
85
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
86
|
-
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
87
|
-
|
|
88
11
|
// MARK: - New API - V3
|
|
89
12
|
|
|
90
13
|
// MARK: Spike SDK level
|
|
@@ -186,8 +109,6 @@ RCT_EXTERN_METHOD(getSleep: (NSString)connectionUUID
|
|
|
186
109
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
187
110
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
188
111
|
|
|
189
|
-
// V3 has to be added because "enableBackgroundDelivery"
|
|
190
|
-
// method from old sdk is still present
|
|
191
112
|
RCT_EXTERN_METHOD(enableBackgroundDeliveryV3: (NSString)connectionUUID
|
|
192
113
|
withStatistics: (NSArray<NSString>)statistics
|
|
193
114
|
metrics: (NSArray<NSString>)metrics
|
package/ios/SpikeSdk.swift
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
import BackgroundTasks
|
|
2
3
|
import SpikeSDK
|
|
4
|
+
import SwiftUI
|
|
3
5
|
import React
|
|
4
6
|
|
|
5
7
|
@objc(SpikeSdk)
|
|
@@ -13,79 +15,9 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
13
15
|
super.init()
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
// MARK: - Connections dictionary
|
|
17
|
-
|
|
18
|
-
/// Do not use this directly, use `addConnection` and `getConnection` instead
|
|
19
|
-
private var _connections: [String: SpikeConnection] = [:]
|
|
20
|
-
private let queue = DispatchQueue(label: "com.spike.rn.SpikeSdk.connections")
|
|
21
|
-
|
|
22
|
-
/// Add new connection to the dictionary in a thread-safe manner
|
|
23
|
-
private func addConnection(_ connection: SpikeConnection, withUUID uuid: String) {
|
|
24
|
-
queue.sync {
|
|
25
|
-
_connections[uuid] = connection
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/// Synchronised read for safe multithreaded usage
|
|
30
|
-
private func getConnection(withUUID uuid: String) -> SpikeConnection? {
|
|
31
|
-
queue.sync {
|
|
32
|
-
_connections[uuid]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
18
|
// MARK: - Spike SDK level
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
withAppId:
|
|
40
|
-
withAuthToken:
|
|
41
|
-
withCustomerEndUserId:
|
|
42
|
-
withCallbackUrl:
|
|
43
|
-
withUseLogger:
|
|
44
|
-
withResolver:withRejecter:)
|
|
45
|
-
func createConnection(uuid: String,
|
|
46
|
-
appId: String,
|
|
47
|
-
authToken: String,
|
|
48
|
-
customerEndUserId: String,
|
|
49
|
-
callbackUrl: String?,
|
|
50
|
-
useLogger: Bool,
|
|
51
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
52
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
53
|
-
Task {
|
|
54
|
-
do {
|
|
55
|
-
let logger = useLogger ? self.createLogger(connectionUUID: uuid) : nil
|
|
56
|
-
let spikeConnection = try await Spike.createConnection(
|
|
57
|
-
appId: appId,
|
|
58
|
-
authToken: authToken,
|
|
59
|
-
customerEndUserId: customerEndUserId,
|
|
60
|
-
callbackUrl: callbackUrl != nil ? URL(string: callbackUrl!) : nil,
|
|
61
|
-
logger: logger)
|
|
62
|
-
addConnection(spikeConnection, withUUID: uuid)
|
|
63
|
-
resolve(Void())
|
|
64
|
-
} catch let error {
|
|
65
|
-
spikeReject(with: error, reject: reject)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@objc(getBackgroundConnections:
|
|
71
|
-
withRejecter:)
|
|
72
|
-
func getBackgroundConnections(resolve: @escaping RCTPromiseResolveBlock,
|
|
73
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
74
|
-
Task {
|
|
75
|
-
do {
|
|
76
|
-
let spikeConnections = try await Spike.getBackgroundConnections()
|
|
77
|
-
var connectionsUUIDs: [String] = []
|
|
78
|
-
for connection in spikeConnections {
|
|
79
|
-
let uuid = UUID().uuidString
|
|
80
|
-
addConnection(connection, withUUID: uuid)
|
|
81
|
-
connectionsUUIDs.append(uuid)
|
|
82
|
-
}
|
|
83
|
-
resolve(connectionsUUIDs)
|
|
84
|
-
} catch let error {
|
|
85
|
-
spikeReject(with: error, reject: reject)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
19
|
+
|
|
20
|
+
private let queue = DispatchQueue(label: "com.spike.rn.SpikeSdk.connections")
|
|
89
21
|
|
|
90
22
|
@objc(isHealthDataAvailable:
|
|
91
23
|
withRejecter:)
|
|
@@ -96,359 +28,17 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
96
28
|
resolve(isAvailable)
|
|
97
29
|
}
|
|
98
30
|
}
|
|
99
|
-
|
|
100
|
-
@objc(ensurePermissionsAreGranted:
|
|
101
|
-
withResolver:
|
|
102
|
-
withRejecter:)
|
|
103
|
-
func ensurePermissionsAreGranted(permissions: [String],
|
|
104
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
105
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
106
|
-
Task {
|
|
107
|
-
do {
|
|
108
|
-
let dataTypes = permissions.map { SpikeDataTypeMapper.mapDataType($0) }
|
|
109
|
-
try await Spike.ensurePermissionsAreGranted(permissions: dataTypes)
|
|
110
|
-
resolve(Void())
|
|
111
|
-
} catch let error {
|
|
112
|
-
spikeReject(with: error, reject: reject)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// MARK: SpikeConnection level
|
|
118
|
-
|
|
119
|
-
@objc(getAppId:
|
|
120
|
-
withResolver:
|
|
121
|
-
withRejecter:)
|
|
122
|
-
func getAppId(connectionUUID: String,
|
|
123
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
124
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
125
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
126
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
do {
|
|
131
|
-
let value = try connection.getAppId()
|
|
132
|
-
resolve(value)
|
|
133
|
-
} catch let error {
|
|
134
|
-
spikeReject(with: error, reject: reject)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@objc(getSpikeEndUserId:
|
|
139
|
-
withResolver:
|
|
140
|
-
withRejecter:)
|
|
141
|
-
func getSpikeEndUserId(connectionUUID: String,
|
|
142
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
143
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
144
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
145
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
do {
|
|
150
|
-
let value = try connection.getSpikeEndUserId()
|
|
151
|
-
resolve(value)
|
|
152
|
-
} catch let error {
|
|
153
|
-
spikeReject(with: error, reject: reject)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@objc(getCustomerEndUserId:
|
|
158
|
-
withResolver:
|
|
159
|
-
withRejecter:)
|
|
160
|
-
func getCustomerEndUserId(connectionUUID: String,
|
|
161
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
162
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
163
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
164
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
do {
|
|
169
|
-
let value = try connection.getCustomerEndUserId()
|
|
170
|
-
resolve(value)
|
|
171
|
-
} catch let error {
|
|
172
|
-
spikeReject(with: error, reject: reject)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@objc(close:
|
|
177
|
-
withResolver:
|
|
178
|
-
withRejecter:)
|
|
179
|
-
func close(connectionUUID: String,
|
|
180
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
181
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
182
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
183
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
184
|
-
return
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
do {
|
|
188
|
-
try connection.close()
|
|
189
|
-
resolve(Void())
|
|
190
|
-
} catch let error {
|
|
191
|
-
spikeReject(with: error, reject: reject)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
@objc(extractData:
|
|
196
|
-
withDataType:
|
|
197
|
-
withResolver:
|
|
198
|
-
withRejecter:)
|
|
199
|
-
func extractData(connectionUUID: String,
|
|
200
|
-
dataType: String,
|
|
201
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
202
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
203
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
204
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
205
|
-
return
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
Task {
|
|
209
|
-
do {
|
|
210
|
-
let result = try await SpikeDataTypeMapper.extractData(dataType,
|
|
211
|
-
connection: connection)
|
|
212
|
-
if let dataString = result {
|
|
213
|
-
resolve(dataString)
|
|
214
|
-
} else {
|
|
215
|
-
spikeReject(with: SpikeDataExtractionException(), reject: reject)
|
|
216
|
-
}
|
|
217
|
-
} catch let error {
|
|
218
|
-
spikeReject(with: error, reject: reject)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@objc(extractDataInRange:
|
|
224
|
-
withDataType:
|
|
225
|
-
withFromDateMillis:
|
|
226
|
-
withToDateMillis:
|
|
227
|
-
withResolver:
|
|
228
|
-
withRejecter:)
|
|
229
|
-
func extractDataInRange(connectionUUID: String,
|
|
230
|
-
dataType: String,
|
|
231
|
-
fromDateMillis: Double,
|
|
232
|
-
toDateMillis: Double,
|
|
233
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
234
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
235
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
236
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
Task {
|
|
241
|
-
do {
|
|
242
|
-
let fromDate = Date(timeIntervalSince1970: fromDateMillis/1000)
|
|
243
|
-
let toDate = Date(timeIntervalSince1970: toDateMillis/1000)
|
|
244
|
-
let result = try await SpikeDataTypeMapper.extractDataInRange(dataType,
|
|
245
|
-
connection: connection,
|
|
246
|
-
from: fromDate,
|
|
247
|
-
to: toDate)
|
|
248
|
-
if let dataString = result {
|
|
249
|
-
resolve(dataString)
|
|
250
|
-
} else {
|
|
251
|
-
spikeReject(with: SpikeDataExtractionException(), reject: reject)
|
|
252
|
-
}
|
|
253
|
-
} catch let error {
|
|
254
|
-
spikeReject(with: error, reject: reject)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// MARK: SpikeWebhookConnection level
|
|
260
|
-
|
|
261
|
-
@objc(getCallbackUrl:
|
|
262
|
-
withResolver:
|
|
263
|
-
withRejecter:)
|
|
264
|
-
func getCallbackUrl(connectionUUID: String,
|
|
265
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
266
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
267
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
268
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
269
|
-
return
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
do {
|
|
273
|
-
let value = try connection.getCallbackUrl()
|
|
274
|
-
resolve(value.absoluteString)
|
|
275
|
-
} catch let error {
|
|
276
|
-
spikeReject(with: error, reject: reject)
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
@objc(extractAndPostData:
|
|
281
|
-
withDataType:
|
|
282
|
-
withResolver:
|
|
283
|
-
withRejecter:)
|
|
284
|
-
func extractAndPostData(connectionUUID: String,
|
|
285
|
-
dataType: String,
|
|
286
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
287
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
288
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
289
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
Task {
|
|
294
|
-
do {
|
|
295
|
-
let result = try await SpikeDataTypeMapper.extractAndPostData(dataType,
|
|
296
|
-
connection: connection)
|
|
297
|
-
if let dataString = result {
|
|
298
|
-
resolve(dataString)
|
|
299
|
-
} else {
|
|
300
|
-
spikeReject(with: SpikeDataExtractionException(), reject: reject)
|
|
301
|
-
}
|
|
302
|
-
} catch let error {
|
|
303
|
-
spikeReject(with: error, reject: reject)
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
@objc(extractAndPostDataInRange:
|
|
309
|
-
withDataType:
|
|
310
|
-
withFromDateMillis:
|
|
311
|
-
withToDateMillis:
|
|
312
|
-
withResolver:
|
|
313
|
-
withRejecter:)
|
|
314
|
-
func extractAndPostDataInRange(connectionUUID: String,
|
|
315
|
-
dataType: String,
|
|
316
|
-
fromDateMillis: Double,
|
|
317
|
-
toDateMillis: Double,
|
|
318
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
319
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
320
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
321
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
322
|
-
return
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
Task {
|
|
326
|
-
do {
|
|
327
|
-
let fromDate = Date(timeIntervalSince1970: fromDateMillis/1000)
|
|
328
|
-
let toDate = Date(timeIntervalSince1970: toDateMillis/1000)
|
|
329
|
-
let result = try await SpikeDataTypeMapper.extractAndPostDataInRange(dataType,
|
|
330
|
-
connection: connection,
|
|
331
|
-
from: fromDate,
|
|
332
|
-
to: toDate)
|
|
333
|
-
if let dataString = result {
|
|
334
|
-
resolve(dataString)
|
|
335
|
-
} else {
|
|
336
|
-
spikeReject(with: SpikeDataExtractionException(), reject: reject)
|
|
337
|
-
}
|
|
338
|
-
} catch let error {
|
|
339
|
-
spikeReject(with: error, reject: reject)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
@objc(enableBackgroundDelivery:
|
|
345
|
-
withDataTypes:
|
|
346
|
-
withResolver:
|
|
347
|
-
withRejecter:)
|
|
348
|
-
func enableBackgroundDelivery(connectionUUID: String,
|
|
349
|
-
dataTypes: [String],
|
|
350
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
351
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
352
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
353
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
354
|
-
return
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
Task {
|
|
358
|
-
do {
|
|
359
|
-
let types = dataTypes.map { SpikeDataTypeMapper.mapDataType($0) }
|
|
360
|
-
try await connection.enableBackgroundDelivery(dataTypes: types)
|
|
361
|
-
resolve(Void())
|
|
362
|
-
} catch let error {
|
|
363
|
-
spikeReject(with: error, reject: reject)
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
@objc(getBackgroundDeliveryDataTypes:
|
|
369
|
-
withResolver:
|
|
370
|
-
withRejecter:)
|
|
371
|
-
func getBackgroundDeliveryDataTypes(connectionUUID: String,
|
|
372
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
373
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
374
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
375
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
376
|
-
return
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
Task {
|
|
380
|
-
do {
|
|
381
|
-
let dataTypes = try await connection.getBackgroundDeliveryDataTypes()
|
|
382
|
-
let dataTypesString = dataTypes.map { SpikeDataTypeMapper.mapDataTypeToString($0) }
|
|
383
|
-
resolve(dataTypesString)
|
|
384
|
-
} catch let error {
|
|
385
|
-
spikeReject(with: error, reject: reject)
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
@objc(setListener:
|
|
391
|
-
withResolver:
|
|
392
|
-
withRejecter:)
|
|
393
|
-
func setListener(connectionUUID: String,
|
|
394
|
-
resolve: @escaping RCTPromiseResolveBlock,
|
|
395
|
-
reject: @escaping RCTPromiseRejectBlock) {
|
|
396
|
-
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
397
|
-
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
398
|
-
return
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
do {
|
|
402
|
-
let listener = createListener(connectionUUID: connectionUUID)
|
|
403
|
-
try connection.setListener(listener: listener)
|
|
404
|
-
resolve(Void())
|
|
405
|
-
} catch let error {
|
|
406
|
-
spikeReject(with: error, reject: reject)
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
31
|
+
|
|
410
32
|
// MARK: Supported events
|
|
411
|
-
|
|
33
|
+
|
|
412
34
|
override func supportedEvents() -> [String]! {
|
|
413
35
|
return [
|
|
414
|
-
"onDebug",
|
|
415
|
-
"onInfo",
|
|
416
|
-
"onError",
|
|
417
|
-
"onBackgroundLog",
|
|
418
36
|
"onSdkLog",
|
|
419
37
|
]
|
|
420
38
|
}
|
|
421
|
-
|
|
422
|
-
// MARK: Private methods
|
|
423
|
-
|
|
424
|
-
private func createLogger(connectionUUID: String) -> SpikeLogger {
|
|
425
|
-
return SpikeConnectionLogger(connectionUUID: connectionUUID) { [weak self] connectionUUID, level, message in
|
|
426
|
-
let body = [
|
|
427
|
-
"connectionUUID": connectionUUID,
|
|
428
|
-
"message": message
|
|
429
|
-
]
|
|
430
|
-
switch level {
|
|
431
|
-
case .debug:
|
|
432
|
-
self?.sendEvent(withName: "onDebug", body: body)
|
|
433
|
-
case .info:
|
|
434
|
-
self?.sendEvent(withName: "onInfo", body: body)
|
|
435
|
-
case .error:
|
|
436
|
-
self?.sendEvent(withName: "onError", body: body)
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
39
|
|
|
441
|
-
|
|
442
|
-
return SpikeConnectionListener(connectionUUID: connectionUUID) { [weak self] connectionUUID, log in
|
|
443
|
-
let body = [
|
|
444
|
-
"connectionUUID": connectionUUID,
|
|
445
|
-
"log": log
|
|
446
|
-
]
|
|
447
|
-
self?.sendEvent(withName: "onBackgroundLog", body: body)
|
|
448
|
-
}
|
|
449
|
-
}
|
|
40
|
+
// MARK: Private methods
|
|
450
41
|
|
|
451
|
-
|
|
452
42
|
private func spikeReject(with error: Error, reject: RCTPromiseRejectBlock) {
|
|
453
43
|
let message = (error as? SpikeException)?.description
|
|
454
44
|
reject(
|
package/lib/commonjs/Spike.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setLogCallback = exports.isPackageInstalled = exports.isHealthDataAvailable = exports.
|
|
6
|
+
exports.setLogCallback = exports.isPackageInstalled = exports.isHealthDataAvailable = exports.createConnectionAPIv3Legacy = exports.createConnectionAPIv3 = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
-
var _SpikeConnection = require("./SpikeConnection");
|
|
9
8
|
var _SpikeException = require("./SpikeException");
|
|
10
9
|
var _SpikeSdk = require("./SpikeSdk");
|
|
11
10
|
var _SpikeRNConnectionAPIv = require("./v3/SpikeRNConnectionAPIv3");
|
|
@@ -13,58 +12,6 @@ var _version = require("./version");
|
|
|
13
12
|
/**
|
|
14
13
|
* @ignore
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use createConnectionAPIv3 instead. See https://docs.spikeapi.com/sdk-docs/react-native/usage-guide
|
|
19
|
-
* @ignore
|
|
20
|
-
*/
|
|
21
|
-
const createConnection = async (config, logger) => {
|
|
22
|
-
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
23
|
-
try {
|
|
24
|
-
const connectionUUID = generateUUID();
|
|
25
|
-
const spikeConnection = new _SpikeConnection.SpikeConnection(connectionUUID, logger);
|
|
26
|
-
await _SpikeSdk.SpikeSdk.createConnection(connectionUUID, config.appId, config.authToken, config.customerEndUserId, config.callbackUrl ?? null, !!logger);
|
|
27
|
-
return spikeConnection;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw (0, _SpikeException.unwrapSpikeException)(error);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated Deprecated
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
exports.createConnection = createConnection;
|
|
38
|
-
const getBackgroundConnections = async () => {
|
|
39
|
-
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
40
|
-
try {
|
|
41
|
-
const connectionUUIDs = await _SpikeSdk.SpikeSdk.getBackgroundConnections();
|
|
42
|
-
const connections = connectionUUIDs.map(uuid => new _SpikeConnection.SpikeConnection(uuid));
|
|
43
|
-
return connections;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw (0, _SpikeException.unwrapSpikeException)(error);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated Deprecated
|
|
51
|
-
* @ignore
|
|
52
|
-
*/
|
|
53
|
-
exports.getBackgroundConnections = getBackgroundConnections;
|
|
54
|
-
const ensurePermissionsAreGranted = async permissions => {
|
|
55
|
-
if (_reactNative.Platform.OS !== 'ios') return;
|
|
56
|
-
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
57
|
-
try {
|
|
58
|
-
await _SpikeSdk.SpikeSdk.ensurePermissionsAreGranted(permissions.map(permissionType => permissionType.rawValue));
|
|
59
|
-
} catch (error) {
|
|
60
|
-
throw (0, _SpikeException.unwrapSpikeException)(error);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @ignore
|
|
66
|
-
*/
|
|
67
|
-
exports.ensurePermissionsAreGranted = ensurePermissionsAreGranted;
|
|
68
15
|
const isPackageInstalled = async () => {
|
|
69
16
|
if (_reactNative.Platform.OS !== 'android') return true;
|
|
70
17
|
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
@@ -196,13 +143,10 @@ exports.createConnectionAPIv3Legacy = createConnectionAPIv3Legacy;
|
|
|
196
143
|
const setLogCallback = async callback => {
|
|
197
144
|
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException("No SpikeSDK found");
|
|
198
145
|
try {
|
|
199
|
-
// Set up event listener for both iOS and Android
|
|
200
146
|
const eventEmitter = new _reactNative.NativeEventEmitter(_SpikeSdk.SpikeSdk);
|
|
201
147
|
const subscription = eventEmitter.addListener('onSdkLog', event => {
|
|
202
148
|
callback(event.level, event.message);
|
|
203
149
|
});
|
|
204
|
-
|
|
205
|
-
// Store subscription for potential cleanup
|
|
206
150
|
_SpikeSdk.SpikeSdk._logSubscription = subscription;
|
|
207
151
|
await _SpikeSdk.SpikeSdk.setLogCallback(callback);
|
|
208
152
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_SpikeException","_SpikeSdk","_SpikeRNConnectionAPIv","_version","isPackageInstalled","Platform","OS","SpikeSdk","SpikeException","error","unwrapSpikeException","exports","isHealthDataAvailable","generateUUID","S4","str","uuid","i","push","Math","floor","random","length","join","createConnectionAPIv3","applicationId","signature","endUserId","setWrapper","SPIKE_SDK_VERSION","connectionUUID","spikeConnection","SpikeRNConnectionAPIv3","createConnectionAPIv3Legacy","appId","authToken","customerEndUserId","setLogCallback","callback","eventEmitter","NativeEventEmitter","subscription","addListener","event","level","message","_logSubscription"],"sourceRoot":"../../src","sources":["Spike.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAGA;AACA;AACA;AACA,MAAMK,kBAAkB,GAAG,MAAAA,CAAA,KAA8B;EACvD,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE,OAAO,IAAI;EAC1C,IAAI,CAACC,kBAAQ,EAAE,MAAM,IAAIC,8BAAc,CAAC,CAAC;EAEzC,IAAI;IACF,OAAO,MAAMD,kBAAQ,CAACH,kBAAkB,CAAC,CAAC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