From d8ca49aef335aaaa09ff2f308985567dcf594942 Mon Sep 17 00:00:00 2001 From: pavel-kuznetsov-hypertrack Date: Mon, 20 Nov 2023 22:35:08 +0200 Subject: [PATCH 1/3] Update HyperTrack SDK iOS to 5.0.7 and Android to 7.0.9 --- CHANGELOG.md | 13 +- android/build.gradle | 2 +- .../sdk/flutter/FlutterSerialization.kt | 5 +- .../sdk/flutter/HyperTrackPlugin.kt | 91 ++++++++----- .../flutter/common/HyperTrackSdkWrapper.kt | 18 +-- .../sdk/flutter/common/Serialization.kt | 120 +++++++++--------- .../sdk/flutter/common/WrapperResult.kt | 5 +- docs/__404error.html | 2 +- .../HyperTrackError.html | 2 +- .../HyperTrackError/HyperTrackError.html | 2 +- .../HyperTrackError/values-constant.html | 2 +- .../data_types_hypertrack_error-library.html | 2 +- docs/data_types_json/JSON-class.html | 2 +- docs/data_types_json/JSON/JSON.html | 2 +- docs/data_types_json/JSON/fromMap.html | 2 +- docs/data_types_json/JSON/fromString.html | 2 +- docs/data_types_json/JSON/serialize.html | 2 +- docs/data_types_json/JSONArray-class.html | 2 +- docs/data_types_json/JSONArray/JSONArray.html | 2 +- docs/data_types_json/JSONArray/items.html | 2 +- docs/data_types_json/JSONArray/serialize.html | 2 +- docs/data_types_json/JSONBool-class.html | 2 +- docs/data_types_json/JSONBool/JSONBool.html | 2 +- docs/data_types_json/JSONBool/serialize.html | 2 +- docs/data_types_json/JSONBool/value.html | 2 +- docs/data_types_json/JSONNull-class.html | 2 +- docs/data_types_json/JSONNull/JSONNull.html | 2 +- docs/data_types_json/JSONNull/serialize.html | 2 +- docs/data_types_json/JSONNumber-class.html | 2 +- .../JSONNumber/JSONNumber.html | 2 +- .../data_types_json/JSONNumber/serialize.html | 2 +- docs/data_types_json/JSONNumber/value.html | 2 +- docs/data_types_json/JSONObject-class.html | 2 +- .../JSONObject/JSONObject.html | 2 +- docs/data_types_json/JSONObject/fields.html | 2 +- .../data_types_json/JSONObject/serialize.html | 2 +- docs/data_types_json/JSONString-class.html | 2 +- .../JSONString/JSONString.html | 2 +- .../data_types_json/JSONString/serialize.html | 2 +- docs/data_types_json/JSONString/value.html | 2 +- .../data_types_json-library.html | 2 +- docs/data_types_json/fromMap.html | 2 +- docs/data_types_location/Location-class.html | 2 +- .../Location/Location.html | 2 +- .../Location/latitude.html | 2 +- .../Location/longitude.html | 2 +- .../data_types_location-library.html | 2 +- .../Errors-class.html | 2 +- .../Errors/Errors.html | 2 +- .../LocationError-class.html | 2 +- .../LocationError/LocationError.errors.html | 2 +- .../LocationError.notRunning.html | 2 +- .../LocationError/LocationError.starting.html | 2 +- .../NotRunning-class.html | 2 +- .../NotRunning/NotRunning.html | 2 +- .../Starting-class.html | 2 +- .../Starting/Starting.html | 2 +- .../data_types_location_error-library.html | 2 +- .../LocationWithDeviation-class.html | 2 +- .../LocationWithDeviation.html | 2 +- .../LocationWithDeviation/deviation.html | 2 +- .../LocationWithDeviation/location.html | 2 +- ...types_location_with_deviation-library.html | 2 +- docs/data_types_result/Failure-class.html | 2 +- docs/data_types_result/Failure/Failure.html | 2 +- docs/data_types_result/Result-class.html | 2 +- .../Result/Result.error.html | 2 +- .../Result/Result.success.html | 2 +- docs/data_types_result/Success-class.html | 2 +- docs/data_types_result/Success/Success.html | 2 +- docs/data_types_result/Success/value.html | 2 +- .../data_types_result-library.html | 2 +- docs/hypertrack/HyperTrack-class.html | 2 +- docs/hypertrack/HyperTrack/HyperTrack.html | 2 +- docs/hypertrack/HyperTrack/addGeotag.html | 2 +- .../addGeotagWithExpectedLocation.html | 2 +- docs/hypertrack/HyperTrack/deviceId.html | 2 +- docs/hypertrack/HyperTrack/errors.html | 2 +- .../HyperTrack/errorsSubscription.html | 2 +- docs/hypertrack/HyperTrack/isAvailable.html | 2 +- .../HyperTrack/isAvailableSubscription.html | 2 +- docs/hypertrack/HyperTrack/isTracking.html | 2 +- .../HyperTrack/isTrackingSubscription.html | 2 +- docs/hypertrack/HyperTrack/locate.html | 2 +- docs/hypertrack/HyperTrack/location.html | 2 +- .../HyperTrack/locationSubscription.html | 2 +- docs/hypertrack/HyperTrack/metadata.html | 2 +- docs/hypertrack/HyperTrack/name.html | 2 +- .../hypertrack/HyperTrack/setIsAvailable.html | 2 +- docs/hypertrack/HyperTrack/setIsTracking.html | 2 +- docs/hypertrack/HyperTrack/setMetadata.html | 2 +- docs/hypertrack/HyperTrack/setName.html | 2 +- docs/hypertrack/hypertrack-library.html | 2 +- docs/index.html | 2 +- docs/search.html | 2 +- ios/hypertrack_plugin.podspec | 4 +- pubspec.yaml | 2 +- 97 files changed, 232 insertions(+), 204 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d391d879..3ef11a90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.3] - 2023-11-20 + +### Changed + +- Updated HyperTrack SDK iOS to 5.0.7 +- Updated HyperTrack SDK Android to 7.0.9 + ## [2.0.2] - 2023-11-10 ### Changed -- Updated HyperTrack SDK iOS to 5.0.6 -- Updated HyperTrack SDK Android to 7.0.8 +- Updated HyperTrack SDK iOS to [5.0.6](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.6) +- Updated HyperTrack SDK Android to [7.0.8](https://github.com/hypertrack/sdk-android/releases/tag/7.0.8) ## [2.0.1] - 2023-10-16 @@ -242,6 +249,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Android SDK version updated to 4.8.0 ## [0.1.2] - 2020-09-28 +[2.0.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.3 + #### Changed diff --git a/android/build.gradle b/android/build.gradle index 109b5e7e..100bde31 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -43,7 +43,7 @@ android { disable 'InvalidPackage' } dependencies { - def hyperTrackVersion = "7.0.8" + def hyperTrackVersion = "7.0.9" implementation "com.hypertrack:sdk-android:${hyperTrackVersion}" implementation "com.hypertrack:location-services-google:${hyperTrackVersion}" implementation "com.hypertrack:push-service-firebase:${hyperTrackVersion}" diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/FlutterSerialization.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/FlutterSerialization.kt index 91c20ce7..535d02ca 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/FlutterSerialization.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/FlutterSerialization.kt @@ -6,7 +6,10 @@ import io.flutter.plugin.common.MethodChannel private const val ERROR_CODE_METHOD_CALL = "METHOD_CALL" -internal fun Unit.sendAsFlutterResult(call: MethodCall, flutterResult: MethodChannel.Result) { +internal fun Unit.sendAsFlutterResult( + call: MethodCall, + flutterResult: MethodChannel.Result, +) { return flutterResult.success(null) } diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt index ebc7235e..5fe60592 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt @@ -22,7 +22,6 @@ import java.lang.NullPointerException import java.util.* public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { - // receives method calls from the plugin API private var methodChannel: MethodChannel? = null @@ -69,19 +68,21 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { locationEventChannel = null } - override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { + override fun onMethodCall( + call: MethodCall, + result: MethodChannel.Result, + ) { invokeSdkMethod(call).sendAsFlutterResult(call, result) } - private fun invokeSdkMethod( - call: MethodCall, - ): WrapperResult<*> { - val method = SdkMethod - .values() - .firstOrNull { it.name == call.method } - ?: run { - return Success(NotImplemented) - } + private fun invokeSdkMethod(call: MethodCall): WrapperResult<*> { + val method = + SdkMethod + .values() + .firstOrNull { it.name == call.method } + ?: run { + return Success(NotImplemented) + } return when (method) { SdkMethod.addGeotag -> { withArgs>(call) { args -> @@ -162,31 +163,41 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { private fun initEventChannels(messenger: BinaryMessenger) { errorsEventChannel = EventChannel(messenger, ERRORS_EVENT_CHANNEL_NAME) - errorsEventChannel?.setStreamHandler(object : StreamHandler { - override fun onListen(arguments: Any?, events: EventSink) { - WrapperResult - .tryAsResult { - errorsCancellable = HyperTrack.subscribeToErrors { errors -> - events.success(serializeErrors(errors)) - } - }.crashAppIfError() - } + errorsEventChannel?.setStreamHandler( + object : StreamHandler { + override fun onListen( + arguments: Any?, + events: EventSink, + ) { + WrapperResult + .tryAsResult { + errorsCancellable = + HyperTrack.subscribeToErrors { errors -> + events.success(serializeErrors(errors)) + } + }.crashAppIfError() + } - override fun onCancel(arguments: Any?) { - errorsCancellable?.cancel() - errorsCancellable = null - } - }) + override fun onCancel(arguments: Any?) { + errorsCancellable?.cancel() + errorsCancellable = null + } + }, + ) isTrackingEventChannel = EventChannel(messenger, IS_TRACKING_STATE_EVENT_CHANNEL_NAME) isTrackingEventChannel?.setStreamHandler( object : StreamHandler { - override fun onListen(arguments: Any?, events: EventSink) { + override fun onListen( + arguments: Any?, + events: EventSink, + ) { WrapperResult .tryAsResult { - isTrackingCancellable = HyperTrack.subscribeToIsTracking { isTracking -> - events.success(serializeIsTracking(isTracking)) - } + isTrackingCancellable = + HyperTrack.subscribeToIsTracking { isTracking -> + events.success(serializeIsTracking(isTracking)) + } }.crashAppIfError() } @@ -200,7 +211,10 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { isAvailableEventChannel = EventChannel(messenger, IS_AVAILABLE_EVENT_CHANNEL_NAME) isAvailableEventChannel?.setStreamHandler( object : StreamHandler { - override fun onListen(arguments: Any?, events: EventSink) { + override fun onListen( + arguments: Any?, + events: EventSink, + ) { WrapperResult .tryAsResult { isAvailableCancellable = @@ -220,7 +234,10 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { locationEventChannel = EventChannel(messenger, LOCATION_EVENT_CHANNEL_NAME) locationEventChannel?.setStreamHandler( object : StreamHandler { - override fun onListen(arguments: Any?, events: EventSink) { + override fun onListen( + arguments: Any?, + events: EventSink, + ) { WrapperResult .tryAsResult { locationCancellable = @@ -240,13 +257,17 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler { locateEventChannel = EventChannel(messenger, LOCATE_EVENT_CHANNEL_NAME) locateEventChannel?.setStreamHandler( object : StreamHandler { - override fun onListen(arguments: Any?, events: EventSink) { + override fun onListen( + arguments: Any?, + events: EventSink, + ) { WrapperResult .tryAsResult { locateCancellable?.cancel() - locateCancellable = HyperTrack.locate { locateResult -> - events.success(serializeLocateResult(locateResult)) - } + locateCancellable = + HyperTrack.locate { locateResult -> + events.success(serializeLocateResult(locateResult)) + } }.crashAppIfError() } diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt index ad32339c..55b9ee44 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt @@ -28,20 +28,20 @@ typealias Serialized = Map * It receives serialized params. */ internal object HyperTrackSdkWrapper { - fun addGeotag(args: Serialized): WrapperResult { return deserializeGeotagData(args) .flatMapSuccess { geotag -> // TODO: return proper error if JSON is wrong val geotagMetadata = Json.fromMap(geotag.data)!! - val expectedLocation = geotag - .expectedLocation - ?.let { - HyperTrack.Location( - latitude = it.latitude, - longitude = it.longitude, - ) - } + val expectedLocation = + geotag + .expectedLocation + ?.let { + HyperTrack.Location( + latitude = it.latitude, + longitude = it.longitude, + ) + } if (expectedLocation != null) { HyperTrack .addGeotag(geotagMetadata, expectedLocation) diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt index f1a1460f..d3bf084f 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/Serialization.kt @@ -9,7 +9,6 @@ import com.hypertrack.sdk.android.Result * to Map or List where T is any JSON-compatible type */ internal object Serialization { - fun deserializeIsAvailable(isAvailable: Map): WrapperResult { return parse(isAvailable) { it.assertValue(key = KEY_TYPE, value = TYPE_IS_AVAILABLE) @@ -48,12 +47,14 @@ internal object Serialization { fun deserializeGeotagData(map: Map): WrapperResult { return parse(map) { - val data = it - .get>(KEY_GEOTAG_DATA) - .getOrThrow() - val locationData = it - .getOptional>(KEY_GEOTAG_EXPECTED_LOCATION) - .getOrThrow() + val data = + it + .get>(KEY_GEOTAG_DATA) + .getOrThrow() + val locationData = + it + .getOptional>(KEY_GEOTAG_EXPECTED_LOCATION) + .getOrThrow() val location = locationData?.let { deserializeLocation(it).getOrThrow() } GeotagData(data, location) } @@ -69,19 +70,20 @@ internal object Serialization { fun serializeError(error: HyperTrack.Error): Map { return mapOf( KEY_TYPE to TYPE_ERROR, - KEY_VALUE to when (error) { - HyperTrack.Error.BlockedFromRunning -> "blockedFromRunning" - HyperTrack.Error.InvalidPublishableKey -> "invalidPublishableKey" - HyperTrack.Error.Location.Mocked -> "location.mocked" - HyperTrack.Error.Location.ServicesDisabled -> "location.servicesDisabled" - HyperTrack.Error.Location.ServicesUnavailable -> "location.servicesUnavailable" - HyperTrack.Error.Location.SignalLost -> "location.signalLost" - HyperTrack.Error.NoExemptionFromBackgroundStartRestrictions -> "noExemptionFromBackgroundStartRestrictions" - HyperTrack.Error.Permissions.Location.Denied -> "permissions.location.denied" - HyperTrack.Error.Permissions.Location.InsufficientForBackground -> "permissions.location.insufficientForBackground" - HyperTrack.Error.Permissions.Location.ReducedAccuracy -> "permissions.location.reducedAccuracy" - HyperTrack.Error.Permissions.Notifications.Denied -> "permissions.notifications.denied" - }, + KEY_VALUE to + when (error) { + HyperTrack.Error.BlockedFromRunning -> "blockedFromRunning" + HyperTrack.Error.InvalidPublishableKey -> "invalidPublishableKey" + HyperTrack.Error.Location.Mocked -> "location.mocked" + HyperTrack.Error.Location.ServicesDisabled -> "location.servicesDisabled" + HyperTrack.Error.Location.ServicesUnavailable -> "location.servicesUnavailable" + HyperTrack.Error.Location.SignalLost -> "location.signalLost" + HyperTrack.Error.NoExemptionFromBackgroundStartRestrictions -> "noExemptionFromBackgroundStartRestrictions" + HyperTrack.Error.Permissions.Location.Denied -> "permissions.location.denied" + HyperTrack.Error.Permissions.Location.InsufficientForBackground -> "permissions.location.insufficientForBackground" + HyperTrack.Error.Permissions.Location.ReducedAccuracy -> "permissions.location.reducedAccuracy" + HyperTrack.Error.Permissions.Notifications.Denied -> "permissions.notifications.denied" + }, ) } @@ -119,9 +121,7 @@ internal object Serialization { ) } - fun serializeLocateResult( - locationResult: Result>, - ): Map { + fun serializeLocateResult(locationResult: Result>): Map { return when (locationResult) { is Result.Failure -> { serializeFailure(serializeErrors(locationResult.failure)) @@ -133,9 +133,7 @@ internal object Serialization { } } - fun serializeLocationResult( - locationResult: Result, - ): Map { + fun serializeLocationResult(locationResult: Result): Map { return when (locationResult) { is Result.Failure -> { serializeLocationErrorFailure(locationResult.failure) @@ -155,9 +153,7 @@ internal object Serialization { return serializeSuccess(serializeLocation(location)) } - fun serializeLocationWithDeviationSuccess( - locationWithDeviation: HyperTrack.LocationWithDeviation, - ): Map { + fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Map { return serializeSuccess( serializeLocationWithDeviation( locationWithDeviation, @@ -165,31 +161,33 @@ internal object Serialization { ) } - private fun serializeLocationWithDeviation( - locationWithDeviation: HyperTrack.LocationWithDeviation, - ): Map { + private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Map { return mapOf( KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION, - KEY_VALUE to mapOf( - KEY_LOCATION to serializeLocation(locationWithDeviation.location), - KEY_DEVIATION to locationWithDeviation.deviation, - ), + KEY_VALUE to + mapOf( + KEY_LOCATION to serializeLocation(locationWithDeviation.location), + KEY_DEVIATION to locationWithDeviation.deviation, + ), ) } private fun deserializeLocation(map: Map): WrapperResult { return parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_LOCATION) - val value = it - .get>(KEY_VALUE) - .getOrThrow() - parse(value) { parser -> - val latitude = parser - .get(KEY_LATITUDE) - .getOrThrow() - val longitude = parser - .get(KEY_LONGITUDE) + val value = + it + .get>(KEY_VALUE) .getOrThrow() + parse(value) { parser -> + val latitude = + parser + .get(KEY_LATITUDE) + .getOrThrow() + val longitude = + parser + .get(KEY_LONGITUDE) + .getOrThrow() Location("api").also { it.latitude = latitude it.longitude = longitude @@ -222,10 +220,11 @@ internal object Serialization { fun serializeLocation(location: HyperTrack.Location): Map { return mapOf( KEY_TYPE to TYPE_LOCATION, - KEY_VALUE to mapOf( - KEY_LATITUDE to location.latitude, - KEY_LONGITUDE to location.longitude, - ), + KEY_VALUE to + mapOf( + KEY_LATITUDE to location.latitude, + KEY_LONGITUDE to location.longitude, + ), ) } @@ -242,8 +241,9 @@ internal object Serialization { is HyperTrack.LocationError.Errors -> { mapOf( KEY_TYPE to TYPE_LOCATION_ERROR_ERRORS, - KEY_VALUE to locationError.errors - .map { serializeError(it) }, + KEY_VALUE to + locationError.errors + .map { serializeError(it) }, ) } } @@ -277,9 +277,7 @@ internal object Serialization { private val _exceptions = mutableListOf() val exceptions: List = _exceptions - inline fun get( - key: String, - ): WrapperResult { + inline fun get(key: String): WrapperResult { return try { Success(source[key]!! as T) } catch (e: Exception) { @@ -292,9 +290,7 @@ internal object Serialization { } } - inline fun getOptional( - key: String, - ): WrapperResult { + inline fun getOptional(key: String): WrapperResult { return try { Success(source[key] as T?) } catch (e: Exception) { @@ -321,11 +317,11 @@ internal object Serialization { val source: Any, val exceptions: List, ) : Throwable( - exceptions.joinToString("\n") - .let { - "Invalid input:\n\n${source}\n\n$it" - }, - ) + exceptions.joinToString("\n") + .let { + "Invalid input:\n\n${source}\n\n$it" + }, + ) internal class ParsingException( key: String, diff --git a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/WrapperResult.kt b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/WrapperResult.kt index 1918b386..0c9289eb 100644 --- a/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/WrapperResult.kt +++ b/android/src/main/kotlin/com/hypertrack/sdk/flutter/common/WrapperResult.kt @@ -1,9 +1,7 @@ package com.hypertrack.sdk.flutter.common internal sealed class WrapperResult { - fun flatMapSuccess( - onSuccess: (SuccessType) -> WrapperResult, - ): WrapperResult { + fun flatMapSuccess(onSuccess: (SuccessType) -> WrapperResult): WrapperResult { return when (this) { is Success -> { onSuccess.invoke(this.success) @@ -49,4 +47,5 @@ internal sealed class WrapperResult { } internal data class Success(val success: SuccessType) : WrapperResult() + internal data class Failure(val failure: Throwable) : WrapperResult() diff --git a/docs/__404error.html b/docs/__404error.html index 6f1740c3..304675fd 100644 --- a/docs/__404error.html +++ b/docs/__404error.html @@ -95,7 +95,7 @@
hypertrack_plugin hypertrack_plugin - 2.0.2 + 2.0.3 diff --git a/docs/data_types_hypertrack_error/HyperTrackError.html b/docs/data_types_hypertrack_error/HyperTrackError.html index 8495d2fe..11121410 100644 --- a/docs/data_types_hypertrack_error/HyperTrackError.html +++ b/docs/data_types_hypertrack_error/HyperTrackError.html @@ -430,7 +430,7 @@
hypertrack_error library