hypertrack-sdk-react-native 10.0.3 → 11.0.0

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +2 -2
  4. package/android/build.gradle +5 -1
  5. package/android/gradle.properties +1 -1
  6. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +80 -115
  7. package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +23 -3
  8. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +87 -220
  9. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +11 -9
  10. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +216 -132
  11. package/android/src/main/java/com/reactnativehypertracksdk/common/{Result.kt → WrapperResult.kt} +9 -7
  12. package/hypertrack-sdk-react-native.podspec +1 -1
  13. package/ios/HyperTrackReactNativePlugin.m +13 -11
  14. package/ios/HyperTrackReactNativePlugin.swift +141 -114
  15. package/ios/common/DictionaryDecoder.swift +5 -5
  16. package/ios/common/HyperTrackSDKWrapper.swift +44 -80
  17. package/ios/common/SDKMethod.swift +13 -12
  18. package/ios/common/Serialization.swift +190 -245
  19. package/lib/commonjs/HyperTrack/HyperTrack.js +224 -124
  20. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  21. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js +13 -17
  22. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js.map +1 -1
  23. package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -1
  24. package/lib/commonjs/HyperTrack/data_types/internal/Metadata.js +2 -0
  25. package/lib/commonjs/HyperTrack/data_types/internal/Metadata.js.map +1 -0
  26. package/lib/commonjs/HyperTrack/data_types/internal/Name.js +2 -0
  27. package/lib/commonjs/HyperTrack/data_types/internal/Name.js.map +1 -0
  28. package/lib/commonjs/index.js +0 -7
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/module/HyperTrack/HyperTrack.js +224 -124
  31. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  32. package/lib/module/HyperTrack/data_types/HyperTrackError.js +13 -17
  33. package/lib/module/HyperTrack/data_types/HyperTrackError.js.map +1 -1
  34. package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -1
  35. package/lib/module/HyperTrack/data_types/internal/Metadata.js +2 -0
  36. package/lib/module/HyperTrack/data_types/internal/Metadata.js.map +1 -0
  37. package/lib/module/HyperTrack/data_types/internal/Name.js +2 -0
  38. package/lib/module/HyperTrack/data_types/internal/Name.js.map +1 -0
  39. package/lib/module/index.js +0 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/typescript/HyperTrack/HyperTrack.d.ts +106 -54
  42. package/lib/typescript/HyperTrack/data_types/HyperTrackError.d.ts +59 -17
  43. package/lib/typescript/HyperTrack/data_types/internal/HyperTrackErrorInternal.d.ts +1 -1
  44. package/lib/typescript/HyperTrack/data_types/internal/Metadata.d.ts +4 -0
  45. package/lib/typescript/HyperTrack/data_types/internal/Name.d.ts +7 -0
  46. package/lib/typescript/index.d.ts +0 -1
  47. package/package.json +1 -1
  48. package/src/HyperTrack/HyperTrack.ts +281 -161
  49. package/src/HyperTrack/data_types/HyperTrackError.ts +73 -18
  50. package/src/HyperTrack/data_types/internal/HyperTrackErrorInternal.ts +3 -3
  51. package/src/HyperTrack/data_types/internal/Metadata.ts +4 -0
  52. package/src/HyperTrack/data_types/internal/Name.ts +7 -0
  53. package/src/index.tsx +0 -1
  54. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackError.kt +0 -28
  55. package/android/src/main/java/com/reactnativehypertracksdk/common/LocationError.kt +0 -9
  56. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkInitParams.kt +0 -44
  57. package/ios/common/HyperTrackError.swift +0 -20
  58. package/ios/common/SDKInitParams.swift +0 -13
  59. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js +0 -2
  60. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js.map +0 -1
  61. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js +0 -2
  62. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js.map +0 -1
  63. package/lib/module/HyperTrack/data_types/SdkInitParams.js +0 -2
  64. package/lib/module/HyperTrack/data_types/SdkInitParams.js.map +0 -1
  65. package/lib/module/HyperTrack/data_types/internal/DeviceName.js +0 -2
  66. package/lib/module/HyperTrack/data_types/internal/DeviceName.js.map +0 -1
  67. package/lib/typescript/HyperTrack/data_types/SdkInitParams.d.ts +0 -25
  68. package/lib/typescript/HyperTrack/data_types/internal/DeviceName.d.ts +0 -4
  69. package/src/HyperTrack/data_types/SdkInitParams.ts +0 -28
  70. package/src/HyperTrack/data_types/internal/DeviceName.ts +0 -4
@@ -1,6 +1,8 @@
1
1
  package com.reactnativehypertracksdk.common
2
2
 
3
3
  import android.location.Location
4
+ import com.hypertrack.sdk.android.HyperTrack
5
+ import com.hypertrack.sdk.android.Result
4
6
 
5
7
  /**
6
8
  * Platform-independent serialization code that converts HyperTrack data types
@@ -8,93 +10,250 @@ import android.location.Location
8
10
  */
9
11
  internal object Serialization {
10
12
 
11
- fun serializeErrors(errors: Set<HyperTrackError>): List<Map<String, String>> {
12
- return errors.map {
13
- serializeHypertrackError(it)
13
+ fun deserializeIsAvailable(isAvailable: Map<String, Any?>): WrapperResult<Boolean> {
14
+ return parse(isAvailable) {
15
+ it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_AVAILABLE)
16
+ it
17
+ .get<Boolean>(KEY_VALUE)
18
+ .getOrThrow()
14
19
  }
15
20
  }
16
21
 
17
- fun serializeLocationSuccess(location: Location): Map<String, Any?> {
18
- return serializeSuccess(serializeLocation(location))
22
+ fun deserializeIsTracking(isTracking: Map<String, Any?>): WrapperResult<Boolean> {
23
+ return parse(isTracking) {
24
+ it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_TRACKING)
25
+ it
26
+ .get<Boolean>(KEY_VALUE)
27
+ .getOrThrow()
28
+ }
19
29
  }
20
30
 
21
- fun serializeLocationWithDeviationSuccess(
22
- location: Location,
23
- deviation: Double
24
- ): Map<String, Any?> {
25
- return serializeSuccess(serializeLocationWithDeviation(
26
- location,
27
- deviation
28
- ))
31
+ fun deserializeMetadata(metadata: Map<String, Any?>): WrapperResult<Map<String, Any?>> {
32
+ return parse(metadata) {
33
+ it.assertValue<String>(key = KEY_TYPE, value = TYPE_METADATA)
34
+ it
35
+ .get<Map<String, Any?>>(KEY_VALUE)
36
+ .getOrThrow()
37
+ }
29
38
  }
30
39
 
31
- fun serializeLocationErrorFailure(locationError: LocationError): Map<String, Any?> {
32
- return serializeFailure(serializeLocationError(locationError))
40
+ fun deserializeName(name: Map<String, Any?>): WrapperResult<String> {
41
+ return parse(name) {
42
+ it.assertValue<String>(key = KEY_TYPE, value = TYPE_NAME)
43
+ it
44
+ .get<String>(KEY_VALUE)
45
+ .getOrThrow()
46
+ }
33
47
  }
34
48
 
35
- fun serializeIsTracking(isTracking: Boolean): Map<String, Any?> {
49
+ fun deserializeGeotagData(map: Map<String, Any?>): WrapperResult<GeotagData> {
50
+ return parse(map) {
51
+ val data = it
52
+ .get<Map<String, Any?>>(KEY_GEOTAG_DATA)
53
+ .getOrThrow()
54
+ val locationData = it
55
+ .getOptional<Map<String, Any?>>(KEY_GEOTAG_EXPECTED_LOCATION)
56
+ .getOrThrow()
57
+ val location = locationData?.let { deserializeLocation(it).getOrThrow() }
58
+ GeotagData(data, location)
59
+ }
60
+ }
61
+
62
+ fun serializeDeviceId(deviceId: String): Map<String, Any?> {
36
63
  return mapOf(
37
- KEY_TYPE to TYPE_IS_TRACKING,
38
- KEY_VALUE to isTracking
64
+ KEY_TYPE to TYPE_DEVICE_ID,
65
+ KEY_VALUE to deviceId
66
+ )
67
+ }
68
+
69
+ fun serializeError(error: HyperTrack.Error): Map<String, String> {
70
+ return mapOf(
71
+ KEY_TYPE to TYPE_ERROR,
72
+ KEY_VALUE to when (error) {
73
+ HyperTrack.Error.BlockedFromRunning -> "blockedFromRunning"
74
+ HyperTrack.Error.InvalidPublishableKey -> "invalidPublishableKey"
75
+ HyperTrack.Error.Location.Mocked -> "location.mocked"
76
+ HyperTrack.Error.Location.ServicesDisabled -> "location.servicesDisabled"
77
+ HyperTrack.Error.Location.ServicesUnavailable -> "location.servicesUnavailable"
78
+ HyperTrack.Error.Location.SignalLost -> "location.signalLost"
79
+ HyperTrack.Error.NoExemptionFromBackgroundStartRestrictions -> "noExemptionFromBackgroundStartRestrictions"
80
+ HyperTrack.Error.Permissions.Location.Denied -> "permissions.location.denied"
81
+ HyperTrack.Error.Permissions.Location.InsufficientForBackground -> "permissions.location.insufficientForBackground"
82
+ HyperTrack.Error.Permissions.Location.ReducedAccuracy -> "permissions.location.reducedAccuracy"
83
+ HyperTrack.Error.Permissions.Notifications.Denied -> "permissions.notifications.denied"
84
+ }
39
85
  )
40
86
  }
41
87
 
88
+ fun serializeErrors(errors: Set<HyperTrack.Error>): List<Map<String, String>> {
89
+ return errors.map {
90
+ serializeError(it)
91
+ }
92
+ }
93
+
42
94
  fun serializeIsAvailable(isAvailable: Boolean): Map<String, Any?> {
43
95
  return mapOf(
44
- KEY_TYPE to TYPE_AVAILABILITY,
96
+ KEY_TYPE to TYPE_IS_AVAILABLE,
45
97
  KEY_VALUE to isAvailable
46
98
  )
47
99
  }
48
100
 
49
- fun serializeHypertrackError(error: HyperTrackError): Map<String, String> {
101
+ fun serializeIsTracking(isTracking: Boolean): Map<String, Any?> {
50
102
  return mapOf(
51
- KEY_TYPE to TYPE_HYPERTRACK_ERROR,
52
- KEY_VALUE to error.name
103
+ KEY_TYPE to TYPE_IS_TRACKING,
104
+ KEY_VALUE to isTracking
53
105
  )
54
106
  }
55
107
 
56
- fun serializeDeviceId(deviceId: String): Map<String, Any?> {
108
+ fun serializeMetadata(metadata: Map<String, Any?>): Map<String, Any?> {
57
109
  return mapOf(
58
- KEY_TYPE to TYPE_DEVICE_ID,
59
- KEY_VALUE to deviceId
110
+ KEY_TYPE to TYPE_METADATA,
111
+ KEY_VALUE to metadata
60
112
  )
61
113
  }
62
114
 
63
- fun deserializeDeviceName(name: Map<String, Any?>): Result<String> {
64
- return parse(name) {
65
- it.assertValue<String>(key = KEY_TYPE, value = TYPE_DEVICE_NAME)
66
- it
67
- .get<String>(KEY_VALUE)
68
- .getOrThrow()
115
+ fun serializeName(name: String): Map<String, Any?> {
116
+ return mapOf(
117
+ KEY_TYPE to TYPE_NAME,
118
+ KEY_VALUE to name
119
+ )
120
+ }
121
+
122
+ fun serializeLocateResult(
123
+ locationResult: Result<HyperTrack.Location, Set<HyperTrack.Error>>
124
+ ): Map<String, Any?> {
125
+ return when (locationResult) {
126
+ is Result.Failure -> {
127
+ serializeFailure(serializeErrors(locationResult.failure))
128
+ }
129
+
130
+ is Result.Success -> {
131
+ serializeLocationSuccess(locationResult.success)
132
+ }
69
133
  }
70
134
  }
71
135
 
72
- fun deserializeAvailability(isAvailable: Map<String, Any?>): Result<Boolean> {
73
- return parse(isAvailable) {
74
- it.assertValue<String>(key = KEY_TYPE, value = TYPE_AVAILABILITY)
75
- it
76
- .get<Boolean>(KEY_VALUE)
77
- .getOrThrow()
136
+ fun serializeLocationResult(
137
+ locationResult: Result<HyperTrack.Location, HyperTrack.LocationError>
138
+ ): Map<String, Any?> {
139
+ return when (locationResult) {
140
+ is Result.Failure -> {
141
+ serializeLocationErrorFailure(locationResult.failure)
142
+ }
143
+
144
+ is Result.Success -> {
145
+ serializeLocationSuccess(locationResult.success)
146
+ }
78
147
  }
79
148
  }
80
149
 
81
- fun deserializeGeotagData(map: Map<String, Any?>): Result<GeotagData> {
150
+ fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Map<String, Any?> {
151
+ return serializeFailure(serializeLocationError(locationError))
152
+ }
153
+
154
+ fun serializeLocationSuccess(location: HyperTrack.Location): Map<String, Any?> {
155
+ return serializeSuccess(serializeLocation(location))
156
+ }
157
+
158
+ fun serializeLocationWithDeviationSuccess(
159
+ locationWithDeviation: HyperTrack.LocationWithDeviation,
160
+ ): Map<String, Any?> {
161
+ return serializeSuccess(
162
+ serializeLocationWithDeviation(
163
+ locationWithDeviation
164
+ )
165
+ )
166
+ }
167
+
168
+ private fun serializeLocationWithDeviation(
169
+ locationWithDeviation: HyperTrack.LocationWithDeviation,
170
+ ): Map<String, Any?> {
171
+ return mapOf(
172
+ KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION,
173
+ KEY_VALUE to mapOf(
174
+ KEY_LOCATION to serializeLocation(locationWithDeviation.location),
175
+ KEY_DEVIATION to locationWithDeviation.deviation
176
+ )
177
+ )
178
+ }
179
+
180
+ private fun deserializeLocation(map: Map<String, Any?>): WrapperResult<Location> {
82
181
  return parse(map) {
83
- val data = it
84
- .get<Map<String, Any?>>(KEY_GEOTAG_DATA)
85
- .getOrThrow()
86
- val locationData = it
87
- .getOptional<Map<String, Any?>>(KEY_GEOTAG_EXPECTED_LOCATION)
182
+ it.assertValue<String>(key = KEY_TYPE, value = TYPE_LOCATION)
183
+ val value = it
184
+ .get<Map<String, Any?>>(KEY_VALUE)
88
185
  .getOrThrow()
89
- val location = locationData?.let { deserializeLocation(it).getOrThrow() }
90
- GeotagData(data, location)
186
+ parse(value) { parser ->
187
+ val latitude = parser
188
+ .get<Double>(KEY_LATITUDE)
189
+ .getOrThrow()
190
+ val longitude = parser
191
+ .get<Double>(KEY_LONGITUDE)
192
+ .getOrThrow()
193
+ Location("api").also {
194
+ it.latitude = latitude
195
+ it.longitude = longitude
196
+ }
197
+ }.getOrThrow()
198
+ }
199
+ }
200
+
201
+ private fun serializeFailure(failure: List<Map<String, Any?>>): Map<String, Any?> {
202
+ return mapOf(
203
+ KEY_TYPE to TYPE_RESULT_FAILURE,
204
+ KEY_VALUE to failure
205
+ )
206
+ }
207
+
208
+ private fun serializeFailure(failure: Map<String, Any?>): Map<String, Any?> {
209
+ return mapOf(
210
+ KEY_TYPE to TYPE_RESULT_FAILURE,
211
+ KEY_VALUE to failure
212
+ )
213
+ }
214
+
215
+ private fun serializeSuccess(success: Map<String, Any?>): Map<String, Any?> {
216
+ return mapOf(
217
+ KEY_TYPE to TYPE_RESULT_SUCCESS,
218
+ KEY_VALUE to success
219
+ )
220
+ }
221
+
222
+ fun serializeLocation(location: HyperTrack.Location): Map<String, Any?> {
223
+ return mapOf(
224
+ KEY_TYPE to TYPE_LOCATION,
225
+ KEY_VALUE to mapOf(
226
+ KEY_LATITUDE to location.latitude,
227
+ KEY_LONGITUDE to location.longitude
228
+ )
229
+ )
230
+ }
231
+
232
+
233
+ private fun serializeLocationError(locationError: HyperTrack.LocationError): Map<String, Any?> {
234
+ return when (locationError) {
235
+ HyperTrack.LocationError.NotRunning -> {
236
+ mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_NOT_RUNNING)
237
+ }
238
+
239
+ HyperTrack.LocationError.Starting -> {
240
+ mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_STARTING)
241
+ }
242
+
243
+ is HyperTrack.LocationError.Errors -> {
244
+ mapOf(
245
+ KEY_TYPE to TYPE_LOCATION_ERROR_ERRORS,
246
+ KEY_VALUE to locationError.errors
247
+ .map { serializeError(it) }
248
+ )
249
+ }
91
250
  }
92
251
  }
93
252
 
94
253
  fun <T> parse(
95
254
  source: Map<String, Any?>,
96
255
  parseFunction: (Parser) -> T
97
- ): Result<T> {
256
+ ): WrapperResult<T> {
98
257
  val parser = Parser(source)
99
258
  return try {
100
259
  if (parser.exceptions.isEmpty()) {
@@ -121,7 +280,7 @@ internal object Serialization {
121
280
 
122
281
  inline fun <reified T> get(
123
282
  key: String
124
- ): Result<T> {
283
+ ): WrapperResult<T> {
125
284
  return try {
126
285
  Success(source[key]!! as T)
127
286
  } catch (e: Exception) {
@@ -136,7 +295,7 @@ internal object Serialization {
136
295
 
137
296
  inline fun <reified T> getOptional(
138
297
  key: String
139
- ): Result<T?> {
298
+ ): WrapperResult<T?> {
140
299
  return try {
141
300
  Success(source[key] as T?)
142
301
  } catch (e: Exception) {
@@ -174,105 +333,30 @@ internal object Serialization {
174
333
  exception: Exception
175
334
  ) : Exception("Invalid value for '$key': $exception", exception)
176
335
 
177
- private fun deserializeLocation(map: Map<String, Any?>): Result<Location> {
178
- return parse(map) {
179
- it.assertValue<String>(key = KEY_TYPE, value = TYPE_LOCATION)
180
- val value = it
181
- .get<Map<String, Any?>>(KEY_VALUE)
182
- .getOrThrow()
183
- parse(value) { parser ->
184
- val latitude = parser
185
- .get<Double>(KEY_LATITUDE)
186
- .getOrThrow()
187
- val longitude = parser
188
- .get<Double>(KEY_LONGITUDE)
189
- .getOrThrow()
190
- Location("api").also {
191
- it.latitude = latitude
192
- it.longitude = longitude
193
- }
194
- }.getOrThrow()
195
- }
196
- }
197
-
198
- private fun serializeLocationWithDeviation(
199
- location: Location,
200
- deviation: Double
201
- ): Map<String, Any?> {
202
- return mapOf(
203
- KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION,
204
- KEY_VALUE to mapOf(
205
- KEY_LOCATION to serializeLocation(location),
206
- KEY_DEVIATION to deviation
207
- )
208
- )
209
- }
210
-
211
- private fun serializeFailure(failure: Map<String, Any?>): Map<String, Any?> {
212
- return mapOf(
213
- KEY_TYPE to TYPE_RESULT_FAILURE,
214
- KEY_VALUE to failure
215
- )
216
- }
217
-
218
- private fun serializeSuccess(success: Map<String, Any?>): Map<String, Any?> {
219
- return mapOf(
220
- KEY_TYPE to TYPE_RESULT_SUCCESS,
221
- KEY_VALUE to success
222
- )
223
- }
224
-
225
- private fun serializeLocation(location: Location): Map<String, Any?> {
226
- return mapOf(
227
- KEY_TYPE to TYPE_LOCATION,
228
- KEY_VALUE to mapOf(
229
- KEY_LATITUDE to location.latitude,
230
- KEY_LONGITUDE to location.longitude
231
- )
232
- )
233
- }
234
-
235
- private fun serializeLocationError(locationError: LocationError): Map<String, Any?> {
236
- return when (locationError) {
237
- NotRunning -> {
238
- mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_NOT_RUNNING)
239
- }
240
- Starting -> {
241
- mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_STARTING)
242
- }
243
- is Errors -> {
244
- mapOf(
245
- KEY_TYPE to TYPE_LOCATION_ERROR_ERRORS,
246
- KEY_VALUE to locationError.errors
247
- .map { serializeHypertrackError(it) }
248
- )
249
- }
250
- }
251
- }
252
-
253
336
  private const val KEY_TYPE = "type"
254
337
  private const val KEY_VALUE = "value"
255
338
 
256
- private const val TYPE_RESULT_SUCCESS = "success"
257
339
  private const val TYPE_RESULT_FAILURE = "failure"
340
+ private const val TYPE_RESULT_SUCCESS = "success"
258
341
 
259
- private const val TYPE_LOCATION = "location"
260
- private const val TYPE_LOCATION_WITH_DEVIATION = "locationWithDeviation"
261
- private const val TYPE_AVAILABILITY = "isAvailable"
262
- private const val TYPE_DEVICE_NAME = "deviceName"
263
342
  private const val TYPE_DEVICE_ID = "deviceID"
264
- private const val TYPE_HYPERTRACK_ERROR = "hyperTrackError"
343
+ private const val TYPE_ERROR = "error"
344
+ private const val TYPE_IS_AVAILABLE = "isAvailable"
265
345
  private const val TYPE_IS_TRACKING = "isTracking"
346
+ private const val TYPE_METADATA = "metadata"
347
+ private const val TYPE_NAME = "name"
348
+ private const val TYPE_LOCATION = "location"
349
+ private const val TYPE_LOCATION_WITH_DEVIATION = "locationWithDeviation"
266
350
 
351
+ private const val TYPE_LOCATION_ERROR_ERRORS = "errors"
267
352
  private const val TYPE_LOCATION_ERROR_NOT_RUNNING = "notRunning"
268
353
  private const val TYPE_LOCATION_ERROR_STARTING = "starting"
269
- private const val TYPE_LOCATION_ERROR_ERRORS = "errors"
270
354
 
271
355
  private const val KEY_LATITUDE = "latitude"
272
356
  private const val KEY_LONGITUDE = "longitude"
273
357
 
358
+ const val KEY_DEVIATION = "deviation"
274
359
  const val KEY_GEOTAG_DATA = "data"
275
360
  const val KEY_GEOTAG_EXPECTED_LOCATION = "expectedLocation"
276
- const val KEY_DEVIATION = "deviation"
277
361
  const val KEY_LOCATION = "location"
278
362
  }
@@ -1,24 +1,26 @@
1
1
  package com.reactnativehypertracksdk.common
2
2
 
3
- internal sealed class Result<SuccessType> {
3
+ internal sealed class WrapperResult<SuccessType> {
4
4
  fun <MappedSuccess> flatMapSuccess(
5
- onSuccess: (SuccessType) -> Result<MappedSuccess>
6
- ): Result<MappedSuccess> {
5
+ onSuccess: (SuccessType) -> WrapperResult<MappedSuccess>
6
+ ): WrapperResult<MappedSuccess> {
7
7
  return when (this) {
8
8
  is Success -> {
9
9
  onSuccess.invoke(this.success)
10
10
  }
11
+
11
12
  is Failure -> {
12
13
  Failure<MappedSuccess>(this.failure)
13
14
  }
14
15
  }
15
16
  }
16
17
 
17
- fun <MappedSuccess> mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): Result<MappedSuccess> {
18
+ fun <MappedSuccess> mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): WrapperResult<MappedSuccess> {
18
19
  return when (this) {
19
20
  is Success -> {
20
21
  Success(onSuccess.invoke(this.success))
21
22
  }
23
+
22
24
  is Failure -> {
23
25
  Failure<MappedSuccess>(this.failure)
24
26
  }
@@ -36,7 +38,7 @@ internal sealed class Result<SuccessType> {
36
38
  }
37
39
 
38
40
  companion object {
39
- fun <SuccessType> tryAsResult(block: () -> SuccessType): Result<SuccessType> {
41
+ fun <SuccessType> tryAsResult(block: () -> SuccessType): WrapperResult<SuccessType> {
40
42
  return try {
41
43
  Success(block.invoke())
42
44
  } catch (e: Exception) {
@@ -46,5 +48,5 @@ internal sealed class Result<SuccessType> {
46
48
  }
47
49
  }
48
50
 
49
- internal data class Success<SuccessType>(val success: SuccessType) : Result<SuccessType>()
50
- internal data class Failure<SuccessType>(val failure: Throwable) : Result<SuccessType>()
51
+ internal data class Success<SuccessType>(val success: SuccessType) : WrapperResult<SuccessType>()
52
+ internal data class Failure<SuccessType>(val failure: Throwable) : WrapperResult<SuccessType>()
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
19
 
20
20
  s.dependency "React-Core"
21
- s.dependency 'HyperTrack/Objective-C', '4.16.1'
21
+ s.dependency 'HyperTrack', '5.0.1'
22
22
 
23
23
  # Don't install the dependencies when we run `pod install` in the old architecture.
24
24
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
@@ -9,36 +9,39 @@ RCT_EXTERN_METHOD(addListener)
9
9
 
10
10
  RCT_EXTERN_METHOD(requiresMainQueueSetup)
11
11
 
12
- RCT_EXTERN_METHOD(initializeSdk:(NSDictionary *)args
12
+ RCT_EXTERN_METHOD(addGeotag:(NSDictionary *)args
13
13
  resolver:(RCTPromiseResolveBlock)resolve
14
14
  rejecter:(RCTPromiseRejectBlock)reject)
15
15
 
16
16
  RCT_EXTERN_METHOD(getDeviceId:(RCTPromiseResolveBlock)resolve
17
17
  rejecter:(RCTPromiseRejectBlock)reject)
18
18
 
19
- RCT_EXTERN_METHOD(getLocation:(RCTPromiseResolveBlock)resolve
19
+ RCT_EXTERN_METHOD(getErrors:(RCTPromiseResolveBlock)resolve
20
20
  rejecter:(RCTPromiseRejectBlock)reject)
21
21
 
22
- RCT_EXTERN_METHOD(startTracking:(RCTPromiseResolveBlock)resolve
22
+ RCT_EXTERN_METHOD(getIsAvailable:(RCTPromiseResolveBlock)resolve
23
23
  rejecter:(RCTPromiseRejectBlock)reject)
24
24
 
25
- RCT_EXTERN_METHOD(stopTracking:(RCTPromiseResolveBlock)resolve
25
+ RCT_EXTERN_METHOD(getIsTracking:(RCTPromiseResolveBlock)resolve
26
+ rejecter:(RCTPromiseRejectBlock)reject)
27
+
28
+ RCT_EXTERN_METHOD(getLocation:(RCTPromiseResolveBlock)resolve
26
29
  rejecter:(RCTPromiseRejectBlock)reject)
27
30
 
28
- RCT_EXTERN_METHOD(isTracking:(RCTPromiseResolveBlock)resolve
31
+ RCT_EXTERN_METHOD(getMetadata:(RCTPromiseResolveBlock)resolve
29
32
  rejecter:(RCTPromiseRejectBlock)reject)
30
33
 
31
- RCT_EXTERN_METHOD(isAvailable:(RCTPromiseResolveBlock)resolve
34
+ RCT_EXTERN_METHOD(getName:(RCTPromiseResolveBlock)resolve
32
35
  rejecter:(RCTPromiseRejectBlock)reject)
33
36
 
34
- RCT_EXTERN_METHOD(sync:(RCTPromiseResolveBlock)resolve
37
+ RCT_EXTERN_METHOD(locate:(RCTPromiseResolveBlock)resolve
35
38
  rejecter:(RCTPromiseRejectBlock)reject)
36
39
 
37
- RCT_EXTERN_METHOD(setAvailability:(NSDictionary *)args
40
+ RCT_EXTERN_METHOD(setIsAvailable:(NSDictionary *)args
38
41
  resolver:(RCTPromiseResolveBlock)resolve
39
42
  rejecter:(RCTPromiseRejectBlock)reject)
40
43
 
41
- RCT_EXTERN_METHOD(setName:(NSDictionary *)args
44
+ RCT_EXTERN_METHOD(setIsTracking:(NSDictionary *)args
42
45
  resolver:(RCTPromiseResolveBlock)resolve
43
46
  rejecter:(RCTPromiseRejectBlock)reject)
44
47
 
@@ -46,9 +49,8 @@ RCT_EXTERN_METHOD(setMetadata:(NSDictionary *)args
46
49
  resolver:(RCTPromiseResolveBlock)resolve
47
50
  rejecter:(RCTPromiseRejectBlock)reject)
48
51
 
49
- RCT_EXTERN_METHOD(addGeotag:(NSDictionary *)args
52
+ RCT_EXTERN_METHOD(setName:(NSDictionary *)args
50
53
  resolver:(RCTPromiseResolveBlock)resolve
51
54
  rejecter:(RCTPromiseRejectBlock)reject)
52
55
 
53
-
54
56
  @end