react-native-spike-sdk 2.4.3 → 2.4.4
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/ios/SpikeSdk.swift +35 -17
- package/ios/SpikeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +3 -0
- package/ios/SpikeSdk.xcodeproj/project.xcworkspace/xcuserdata/jaroslav.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package.json +2 -2
- package/ios/SpikeSdk.xcodeproj/project.xcworkspace/xcuserdata/ekroman.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- /package/ios/SpikeSdk.xcodeproj/xcuserdata/{ekroman.xcuserdatad → jaroslav.xcuserdatad}/xcschemes/xcschememanagement.plist +0 -0
package/ios/SpikeSdk.swift
CHANGED
|
@@ -9,13 +9,31 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
9
9
|
return true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
private var connections: [String: SpikeConnection] = [:]
|
|
13
|
-
|
|
14
12
|
override init() {
|
|
15
13
|
super.init()
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
// MARK:
|
|
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
|
+
// MARK: - Spike SDK level
|
|
19
37
|
|
|
20
38
|
@objc(createConnection:
|
|
21
39
|
withAppId:
|
|
@@ -41,7 +59,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
41
59
|
customerEndUserId: customerEndUserId,
|
|
42
60
|
callbackUrl: callbackUrl != nil ? URL(string: callbackUrl!) : nil,
|
|
43
61
|
logger: logger)
|
|
44
|
-
|
|
62
|
+
addConnection(spikeConnection, withUUID: uuid)
|
|
45
63
|
resolve(Void())
|
|
46
64
|
} catch let error {
|
|
47
65
|
spikeReject(with: error, reject: reject)
|
|
@@ -59,7 +77,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
59
77
|
var connectionsUUIDs: [String] = []
|
|
60
78
|
for connection in spikeConnections {
|
|
61
79
|
let uuid = UUID().uuidString
|
|
62
|
-
|
|
80
|
+
addConnection(connection, withUUID: uuid)
|
|
63
81
|
connectionsUUIDs.append(uuid)
|
|
64
82
|
}
|
|
65
83
|
resolve(connectionsUUIDs)
|
|
@@ -104,7 +122,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
104
122
|
func getAppId(connectionUUID: String,
|
|
105
123
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
106
124
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
107
|
-
guard let connection =
|
|
125
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
108
126
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
109
127
|
return
|
|
110
128
|
}
|
|
@@ -123,7 +141,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
123
141
|
func getSpikeEndUserId(connectionUUID: String,
|
|
124
142
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
125
143
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
126
|
-
guard let connection =
|
|
144
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
127
145
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
128
146
|
return
|
|
129
147
|
}
|
|
@@ -142,7 +160,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
142
160
|
func getCustomerEndUserId(connectionUUID: String,
|
|
143
161
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
144
162
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
145
|
-
guard let connection =
|
|
163
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
146
164
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
147
165
|
return
|
|
148
166
|
}
|
|
@@ -161,7 +179,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
161
179
|
func close(connectionUUID: String,
|
|
162
180
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
163
181
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
164
|
-
guard let connection =
|
|
182
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
165
183
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
166
184
|
return
|
|
167
185
|
}
|
|
@@ -182,7 +200,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
182
200
|
dataType: String,
|
|
183
201
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
184
202
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
185
|
-
guard let connection =
|
|
203
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
186
204
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
187
205
|
return
|
|
188
206
|
}
|
|
@@ -214,7 +232,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
214
232
|
toDateMillis: Double,
|
|
215
233
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
216
234
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
217
|
-
guard let connection =
|
|
235
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
218
236
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
219
237
|
return
|
|
220
238
|
}
|
|
@@ -246,7 +264,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
246
264
|
func getCallbackUrl(connectionUUID: String,
|
|
247
265
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
248
266
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
249
|
-
guard let connection =
|
|
267
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
250
268
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
251
269
|
return
|
|
252
270
|
}
|
|
@@ -267,7 +285,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
267
285
|
dataType: String,
|
|
268
286
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
269
287
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
270
|
-
guard let connection =
|
|
288
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
271
289
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
272
290
|
return
|
|
273
291
|
}
|
|
@@ -299,7 +317,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
299
317
|
toDateMillis: Double,
|
|
300
318
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
301
319
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
302
|
-
guard let connection =
|
|
320
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
303
321
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
304
322
|
return
|
|
305
323
|
}
|
|
@@ -331,7 +349,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
331
349
|
dataTypes: [String],
|
|
332
350
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
333
351
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
334
|
-
guard let connection =
|
|
352
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
335
353
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
336
354
|
return
|
|
337
355
|
}
|
|
@@ -353,7 +371,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
353
371
|
func getBackgroundDeliveryDataTypes(connectionUUID: String,
|
|
354
372
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
355
373
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
356
|
-
guard let connection =
|
|
374
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
357
375
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
358
376
|
return
|
|
359
377
|
}
|
|
@@ -375,7 +393,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
375
393
|
func setListener(connectionUUID: String,
|
|
376
394
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
377
395
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
378
|
-
guard let connection =
|
|
396
|
+
guard let connection = getConnection(withUUID: connectionUUID) else {
|
|
379
397
|
spikeReject(with: SpikeWrapperException(), reject: reject)
|
|
380
398
|
return
|
|
381
399
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-spike-sdk",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"iosVersion": "2.3.2",
|
|
5
5
|
"description": "Spike API for health and productivity data from wearables and IoT devices",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"engines": {
|
|
87
87
|
"node": ">= 16.0.0"
|
|
88
88
|
},
|
|
89
|
-
"packageManager": "
|
|
89
|
+
"packageManager": "yarn@1.22.15",
|
|
90
90
|
"jest": {
|
|
91
91
|
"preset": "react-native",
|
|
92
92
|
"modulePathIgnorePatterns": [
|
|
Binary file
|