Skip to content

Commit 422b93b

Browse files
Add HyperTrack.allowMockLocation (#47)
Update HyperTrack SDK iOS to 5.10.0 and Android to 7.10.0
1 parent 2c65e81 commit 422b93b

35 files changed

+253
-49
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
## [3.8.0] - 2025-01-17
9+
10+
### Added
11+
12+
- New `HyperTrack.getAllowMockLocation()` and `HyperTrack.setAllowMockLocation()` methods which can be used to allow mocking location data.
13+
- Check the [Test with mock locations](https://hypertrack.com/docs/mock-location) guide for more information.
14+
- Note: To avoid issues related to race conditions in your code use this API **only if** modifying the compiled `HyperTrackAllowMockLocation` AndroidManifest.xml/Info.plist value is insufficient for your needs.
15+
- Example: if for some reason you aren't able to recompile with `HyperTrackAllowMockLocation` set to `YES`/`true` for your prod app QA mock location tests and need to set up the value in runtime.
16+
17+
### Changed
18+
19+
- Updated HyperTrack SDK iOS to [5.10.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.10.0)
20+
- Updated HyperTrack SDK Android to [7.10.0](https://github.com/hypertrack/sdk-android/releases/tag/7.10.0)
21+
822
## [3.7.1] - 2024-12-05
923

1024
### Changed
@@ -333,3 +347,4 @@ We are excited to announce the release of HyperTrack Ionic Capacitor SDK 2.0.0,
333347
[3.6.3]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.6.3
334348
[3.7.0]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.7.0
335349
[3.7.1]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.7.1
350+
[3.8.0]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.8.0

HypertrackSdkIonicCapacitor.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Pod::Spec.new do |s|
1414
s.ios.deployment_target = '12.0'
1515
s.dependency 'Capacitor'
1616
s.swift_version = '5.1'
17-
s.dependency 'HyperTrack','5.9.1'
17+
s.dependency 'HyperTrack','5.10.0'
1818
end

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![GitHub](https://img.shields.io/github/license/hypertrack/sdk-ionic-capacitor.svg?color=orange)](./LICENSE)
44
[![npm](https://img.shields.io/npm/v/hypertrack-sdk-ionic-capacitor.svg)](https://www.npmjs.com/package/hypertrack-sdk-ionic-capacitor)
5-
[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.9.1-brightgreen.svg)](https://github.com/hypertrack/sdk-ios)
6-
[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.9.1-brightgreen.svg)](https://github.com/hypertrack/sdk-android)
5+
[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.10.0-brightgreen.svg)](https://github.com/hypertrack/sdk-ios)
6+
[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.10.0-brightgreen.svg)](https://github.com/hypertrack/sdk-android)
77

88
[HyperTrack](https://www.hypertrack.com) lets you add live location tracking to your mobile app. Live location is made available along with ongoing activity, tracking controls and tracking outage with reasons.
99

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ext {
77

88
buildscript {
99
ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '1.9.10'
10-
ext.hypertrack_sdk_version = "7.9.1"
10+
ext.hypertrack_sdk_version = "7.10.0"
1111
ext.firebase_messaging_version = "23.1.1"
1212

1313
repositories {

android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt

+20
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class HyperTrackCapacitorPlugin : Plugin() {
2525
invokeSdkMethod(SdkMethod.addGeotag, call).toPluginCall(call)
2626
}
2727

28+
@PluginMethod
29+
fun getAllowMockLocation(call: PluginCall) {
30+
invokeSdkMethod(SdkMethod.getAllowMockLocation, call).toPluginCall(call)
31+
}
32+
2833
@PluginMethod
2934
fun getDeviceId(call: PluginCall) {
3035
invokeSdkMethod(SdkMethod.getDeviceID, call).toPluginCall(call)
@@ -70,6 +75,11 @@ class HyperTrackCapacitorPlugin : Plugin() {
7075
invokeSdkMethod(SdkMethod.getWorkerHandle, call).toPluginCall(call)
7176
}
7277

78+
@PluginMethod
79+
fun setAllowMockLocation(call: PluginCall) {
80+
invokeSdkMethod(SdkMethod.setAllowMockLocation, call).toPluginCall(call)
81+
}
82+
7383
@PluginMethod
7484
fun setIsAvailable(call: PluginCall) {
7585
invokeSdkMethod(SdkMethod.setIsAvailable, call).toPluginCall(call)
@@ -205,6 +215,10 @@ class HyperTrackCapacitorPlugin : Plugin() {
205215
}
206216
}
207217

218+
SdkMethod.getAllowMockLocation -> {
219+
HyperTrackSdkWrapper.getAllowMockLocation()
220+
}
221+
208222
SdkMethod.getDeviceID -> {
209223
HyperTrackSdkWrapper.getDeviceId()
210224
}
@@ -254,6 +268,12 @@ class HyperTrackCapacitorPlugin : Plugin() {
254268
throw NotImplementedError("Locate is implemented in different way")
255269
}
256270

271+
SdkMethod.setAllowMockLocation -> {
272+
withArgs<Map<String, Any?>, Unit>(argsJson) { args ->
273+
HyperTrackSdkWrapper.setAllowMockLocation(args)
274+
}
275+
}
276+
257277
SdkMethod.setDynamicPublishableKey -> {
258278
throw Error("Not implemented")
259279
}

android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt

+10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package com.hypertrack.sdk.capacitor.common
33
import com.hypertrack.sdk.android.HyperTrack
44
import com.hypertrack.sdk.android.Json
55
import com.hypertrack.sdk.android.Result
6+
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeAllowMockLocation
67
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeDynamicPublishableKey
78
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeGeotagData
89
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeIsAvailable
910
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeIsTracking
1011
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeMetadata
1112
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeName
1213
import com.hypertrack.sdk.capacitor.common.Serialization.deserializeWorkerHandle
14+
import com.hypertrack.sdk.capacitor.common.Serialization.serializeAllowMockLocation
1315
import com.hypertrack.sdk.capacitor.common.Serialization.serializeDeviceId
1416
import com.hypertrack.sdk.capacitor.common.Serialization.serializeDynamicPublishableKey
1517
import com.hypertrack.sdk.capacitor.common.Serialization.serializeErrors
@@ -89,6 +91,8 @@ internal object HyperTrackSdkWrapper {
8991
}
9092
}
9193

94+
fun getAllowMockLocation(): WrapperResult<Serialized> = Success(serializeAllowMockLocation(HyperTrack.allowMockLocation))
95+
9296
fun getDeviceId(): WrapperResult<Serialized> = Success(serializeDeviceId(HyperTrack.deviceID))
9397

9498
fun getDynamicPublishableKey(): WrapperResult<Serialized> = Success(serializeDynamicPublishableKey(HyperTrack.dynamicPublishableKey))
@@ -135,6 +139,12 @@ internal object HyperTrackSdkWrapper {
135139
serializeWorkerHandle(HyperTrack.workerHandle),
136140
)
137141

142+
fun setAllowMockLocation(args: Serialized): WrapperResult<Unit> =
143+
deserializeAllowMockLocation(args)
144+
.mapSuccess { allowMockLocation ->
145+
HyperTrack.allowMockLocation = allowMockLocation
146+
}
147+
138148
fun setDynamicPublishableKey(args: Serialized): WrapperResult<Unit> =
139149
deserializeDynamicPublishableKey(args)
140150
.mapSuccess { publishableKey ->

android/src/main/java/com/hypertrack/sdk/capacitor/common/SdkMethod.kt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package com.hypertrack.sdk.capacitor.common
88
*/
99
internal enum class SdkMethod {
1010
addGeotag,
11+
getAllowMockLocation,
1112
getDeviceID,
1213
getDynamicPublishableKey,
1314
getErrors,
@@ -19,6 +20,7 @@ internal enum class SdkMethod {
1920
getOrders,
2021
getWorkerHandle,
2122
locate,
23+
setAllowMockLocation,
2224
setDynamicPublishableKey,
2325
setIsAvailable,
2426
setIsTracking,

android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import com.hypertrack.sdk.android.Result
99
* to Map<String, T> or List<T> where T is any JSON-compatible type
1010
*/
1111
internal object Serialization {
12+
fun deserializeAllowMockLocation(allowMockLocation: Serialized): WrapperResult<Boolean> =
13+
parse(allowMockLocation) {
14+
it.assertValue<String>(key = KEY_TYPE, value = TYPE_ALLOW_MOCK_LOCATION)
15+
it
16+
.get<Boolean>(KEY_VALUE)
17+
.getOrThrow()
18+
}
19+
1220
fun deserializeDynamicPublishableKey(args: Serialized): WrapperResult<String> =
1321
parse(args) {
1422
it.assertValue<String>(key = KEY_TYPE, value = TYPE_DYNAMIC_PUBLISHABLE_KEY)
@@ -89,6 +97,12 @@ internal object Serialization {
8997
.getOrThrow()
9098
}
9199

100+
fun serializeAllowMockLocation(allowMockLocation: Boolean): Serialized =
101+
mapOf(
102+
KEY_TYPE to TYPE_ALLOW_MOCK_LOCATION,
103+
KEY_VALUE to allowMockLocation,
104+
)
105+
92106
fun serializeDeviceId(deviceId: String): Serialized =
93107
mapOf(
94108
KEY_TYPE to TYPE_DEVICE_ID,
@@ -405,6 +419,7 @@ internal object Serialization {
405419
private const val TYPE_RESULT_FAILURE = "failure"
406420
private const val TYPE_RESULT_SUCCESS = "success"
407421

422+
private const val TYPE_ALLOW_MOCK_LOCATION = "allowMockLocation"
408423
private const val TYPE_DEVICE_ID = "deviceID"
409424
private const val TYPE_DYNAMIC_PUBLISHABLE_KEY = "dynamicPublishableKey"
410425
private const val TYPE_ERROR = "error"

docs/assets/search.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)