react-native-spike-sdk 2.4.2 → 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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "platforms": ["ios"],
3
+ "ios": {
4
+ "appDelegateSubscribers": ["SpikeExpoModuleAppDelegateSubscriber"]
5
+ }
6
+ }
@@ -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: Spike SDK level
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
- connections[uuid] = spikeConnection
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
- connections[uuid] = connection
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
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 = connections[connectionUUID] else {
396
+ guard let connection = getConnection(withUUID: connectionUUID) else {
379
397
  spikeReject(with: SpikeWrapperException(), reject: reject)
380
398
  return
381
399
  }
@@ -1,4 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <Workspace
3
3
  version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
4
7
  </Workspace>
@@ -0,0 +1,45 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "..", "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "SpikeExpoModule"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+
11
+ s.description = <<-DESC
12
+ Connect your app to users’ real-time data via a single API and enable new (data-driven) functionality and personalisation
13
+ DESC
14
+
15
+ s.homepage = "https://gitlab.com/spike_api/spike-react-native-sdk.git"
16
+ s.license = { :type => 'MIT', :file => 'LICENSE' }
17
+ s.author = { "SpikeAPI" => "vytenis@spikeapi.com" }
18
+
19
+
20
+ s.source = { :git => "https://gitlab.com/spike_api/spike-react-native-sdk.git", :tag => "#{s.version}" }
21
+
22
+ s.source_files = "**/*.{h,m,mm,swift}"
23
+
24
+ s.platform = :ios, "13.0"
25
+ s.swift_version = "5"
26
+
27
+ s.dependency "React-Core"
28
+ s.dependency 'ExpoModulesCore'
29
+ s.dependency "SpikeSDK", "~> #{package["iosVersion"]}"
30
+
31
+ # Don't install the dependencies when we run `pod install` in the old architecture.
32
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
33
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
34
+ s.pod_target_xcconfig = {
35
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
36
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
37
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
38
+ }
39
+ s.dependency "React-Codegen"
40
+ s.dependency "RCT-Folly"
41
+ s.dependency "RCTRequired"
42
+ s.dependency "RCTTypeSafety"
43
+ s.dependency "ReactCommon/turbomodule/core"
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ import ExpoModulesCore
2
+ import SpikeSDK
3
+
4
+ public class SpikeExpoModuleAppDelegateSubscriber: ExpoAppDelegateSubscriber {
5
+
6
+ public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
7
+ Spike.configure()
8
+ return true
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "react-native-spike-sdk",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
+ "iosVersion": "2.3.2",
4
5
  "description": "Spike API for health and productivity data from wearables and IoT devices",
5
6
  "main": "lib/commonjs/index",
6
7
  "module": "lib/module/index",
@@ -12,8 +13,10 @@
12
13
  "lib",
13
14
  "android",
14
15
  "ios",
16
+ "ios-expo-module",
15
17
  "cpp",
16
18
  "app.plugin.js",
19
+ "expo-module.config.json",
17
20
  "*.podspec",
18
21
  "!lib/typescript/example",
19
22
  "!ios/build",
@@ -83,7 +86,7 @@
83
86
  "engines": {
84
87
  "node": ">= 16.0.0"
85
88
  },
86
- "packageManager": "^yarn@1.22.15",
89
+ "packageManager": "yarn@1.22.15",
87
90
  "jest": {
88
91
  "preset": "react-native",
89
92
  "modulePathIgnorePatterns": [
@@ -5,8 +5,8 @@ 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.4.2"
9
- s.summary = "Spike API for health and productivity data from wearables and IoT devices"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
10
 
11
11
  s.description = <<-DESC
12
12
  Connect your app to users’ real-time data via a single API and enable new (data-driven) functionality and personalisation
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
25
25
  s.swift_version = "5"
26
26
 
27
27
  s.dependency "React-Core"
28
- s.dependency "SpikeSDK", "~> 2.3.2"
28
+ s.dependency "SpikeSDK", "~> #{package["iosVersion"]}"
29
29
 
30
30
  # Don't install the dependencies when we run `pod install` in the old architecture.
31
31
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then