Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.7)
- Updated HyperTrack SDK Android to [7.0.9](https://github.com/hypertrack/sdk-android/releases/tag/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

Expand Down Expand Up @@ -249,8 +256,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1.1] - 2020-06-18

[2.0.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.2

#### Changed

- Android SDK version updated to 4.4.1
Expand All @@ -262,6 +267,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release.

[2.0.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.3
[2.0.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.2
[2.0.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.1
[2.0.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.0
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<Map<String, Any?>>(call) { args ->
Expand Down Expand Up @@ -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()
}

Expand All @@ -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 =
Expand All @@ -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 =
Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ typealias Serialized = Map<String, Any?>
* It receives serialized params.
*/
internal object HyperTrackSdkWrapper {

fun addGeotag(args: Serialized): WrapperResult<Serialized> {
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)
Expand Down
Loading