Skip to content

Commit e4eecd8

Browse files
Add Orders API (#58)
1 parent 3bea371 commit e4eecd8

File tree

131 files changed

+2176
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2176
-191
lines changed

CHANGELOG.md

Lines changed: 102 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
## [2.4.0] - 2024-08-27
9+
10+
### Added
11+
12+
- Support for on-device geofencing via new `HyperTrack.orders["my_order"].isInsideGeofence` property
13+
- To learn more about how to best use this new feature see our guide
14+
here: [Verify shift presence before starting work](https://developer.hypertrack.com/docs/clock-in-out-tagging#verify-shift-presence-before-starting-work)
15+
16+
### Changed
17+
18+
- Updated HyperTrack SDK iOS to [5.7.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.7.0)
19+
- Updated HyperTrack SDK Android
20+
to [7.7.0](https://github.com/hypertrack/sdk-android/releases/tag/7.7.0)
21+
822
## [2.3.0] - 2024-06-22
923

1024
### Added
1125

1226
- New `setWorkerHandle` and `getWorkerHandle` can be used to identify workers
13-
- We observed our customers identify worker devices via `HyperTrack.metadata`, so we decided to make it a first class citizen in our API.
14-
- If you previously used `metadata` to identify workers, we suggest using `workerHandle` for this purpose instead.
27+
- We observed our customers identify worker devices via `HyperTrack.metadata`, so we decided to
28+
make it a first class citizen in our API.
29+
- If you previously used `metadata` to identify workers, we suggest using `workerHandle` for
30+
this purpose instead.
1531

1632
### Changed
1733

1834
- Updated HyperTrack SDK iOS to [5.6.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.6.0)
19-
- Updated HyperTrack SDK Android to [7.6.0](https://github.com/hypertrack/sdk-android/releases/tag/7.6.0)
35+
- Updated HyperTrack SDK Android
36+
to [7.6.0](https://github.com/hypertrack/sdk-android/releases/tag/7.6.0)
2037

2138
## [2.2.3] - 2024-05-24
2239

2340
### Changed
2441

25-
- Updated HyperTrack SDK Android to [7.5.5](https://github.com/hypertrack/sdk-android/releases/tag/7.5.5)
42+
- Updated HyperTrack SDK Android
43+
to [7.5.5](https://github.com/hypertrack/sdk-android/releases/tag/7.5.5)
2644

2745
## [2.2.2] - 2024-05-14
2846

2947
### Changed
3048

3149
- Updated HyperTrack SDK iOS to [5.5.4](https://github.com/hypertrack/sdk-ios/releases/tag/5.5.4)
32-
- Updated HyperTrack SDK Android to [7.5.4](https://github.com/hypertrack/sdk-android/releases/tag/7.5.4)
50+
- Updated HyperTrack SDK Android
51+
to [7.5.4](https://github.com/hypertrack/sdk-android/releases/tag/7.5.4)
3352

3453
## [2.2.1] - 2024-05-03
3554

@@ -41,58 +60,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4160

4261
### Changed
4362

44-
- New `addGeotag` and `addGeotagWithExpectedLocation` methods signature that have `orderHandle` and `orderStatus` parameters. You can use this API when users need to clock in/out of work in your app to honor their work time (see [Clock in/out Tagging](https://hypertrack.com/docs/clock-inout-tracking#add-clock-inout-events-to-a-shift-timeline) guide for more info)
63+
- New `addGeotag` and `addGeotagWithExpectedLocation` methods signature that have `orderHandle`
64+
and `orderStatus` parameters. You can use this API when users need to clock in/out of work in your
65+
app to honor their work time (
66+
see [Clock in/out Tagging](https://hypertrack.com/docs/clock-inout-tracking#add-clock-inout-events-to-a-shift-timeline)
67+
guide for more info)
4568
- Updated HyperTrack SDK iOS to [5.5.2](https://github.com/hypertrack/sdk-ios/releases/tag/5.5.2)
46-
- Updated HyperTrack SDK Android to [7.5.3](https://github.com/hypertrack/sdk-android/releases/tag/7.5.3)
69+
- Updated HyperTrack SDK Android
70+
to [7.5.3](https://github.com/hypertrack/sdk-android/releases/tag/7.5.3)
4771

4872
## [2.1.2] - 2024-02-27
4973

5074
### Changed
5175

52-
- Updated HyperTrack SDK Android to [7.4.3](https://github.com/hypertrack/sdk-android/releases/tag/7.4.3)
76+
- Updated HyperTrack SDK Android
77+
to [7.4.3](https://github.com/hypertrack/sdk-android/releases/tag/7.4.3)
5378

5479
## [2.1.1] - 2024-02-14
5580

5681
### Changed
5782

5883
- Updated HyperTrack SDK iOS to [5.4.1](https://github.com/hypertrack/sdk-ios/releases/tag/5.4.1)
59-
- Updated HyperTrack SDK Android to [7.4.2](https://github.com/hypertrack/sdk-android/releases/tag/7.4.2)
84+
- Updated HyperTrack SDK Android
85+
to [7.4.2](https://github.com/hypertrack/sdk-android/releases/tag/7.4.2)
6086

6187
## [2.1.0] - 2024-01-29
6288

6389
### Changed
6490

6591
- Updated HyperTrack SDK iOS to [5.4.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.4.0)
66-
- Updated HyperTrack SDK Android to [7.4.0](https://github.com/hypertrack/sdk-android/releases/tag/7.4.0)
92+
- Updated HyperTrack SDK Android
93+
to [7.4.0](https://github.com/hypertrack/sdk-android/releases/tag/7.4.0)
6794

6895
## [2.0.4] - 2023-12-01
6996

7097
### Changed
7198

7299
- Updated HyperTrack SDK iOS to [5.0.8](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.8)
73-
- Updated HyperTrack SDK Android to [7.0.10](https://github.com/hypertrack/sdk-android/releases/tag/7.0.10)
100+
- Updated HyperTrack SDK Android
101+
to [7.0.10](https://github.com/hypertrack/sdk-android/releases/tag/7.0.10)
74102
- `minSdkVersion` from 23 to 19 for Android
75103

76104
## [2.0.3] - 2023-11-20
77105

78106
### Changed
79107

80108
- Updated HyperTrack SDK iOS to [5.0.7](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.7)
81-
- Updated HyperTrack SDK Android to [7.0.9](https://github.com/hypertrack/sdk-android/releases/tag/7.0.9)
109+
- Updated HyperTrack SDK Android
110+
to [7.0.9](https://github.com/hypertrack/sdk-android/releases/tag/7.0.9)
82111

83112
## [2.0.2] - 2023-11-10
84113

85114
### Changed
86115

87116
- Updated HyperTrack SDK iOS to [5.0.6](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.6)
88-
- Updated HyperTrack SDK Android to [7.0.8](https://github.com/hypertrack/sdk-android/releases/tag/7.0.8)
117+
- Updated HyperTrack SDK Android
118+
to [7.0.8](https://github.com/hypertrack/sdk-android/releases/tag/7.0.8)
89119

90120
## [2.0.1] - 2023-10-16
91121

92122
### Changed
93123

94124
- Updated HyperTrack SDK iOS to [5.0.4](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.4)
95-
- Updated HyperTrack SDK Android to [7.0.6](https://github.com/hypertrack/sdk-android/releases/tag/7.0.6)
125+
- Updated HyperTrack SDK Android
126+
to [7.0.6](https://github.com/hypertrack/sdk-android/releases/tag/7.0.6)
96127

97128
### Fixed
98129

@@ -108,8 +139,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
108139
- `name` getter
109140
- `metadata` getter
110141
- HyperTrackError types:
111-
- `noExemptionFromBackgroundStartRestrictions`
112-
- `permissionsNotificationsDenied`
142+
- `noExemptionFromBackgroundStartRestrictions`
143+
- `permissionsNotificationsDenied`
113144

114145
### Changed
115146

@@ -119,17 +150,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
119150
- Updated HyperTrack iOS SDK to [5.0.2](https://github.com/hypertrack/sdk-ios/releases/tag/5.0.2)
120151
- The whole HyperTrack API is now static
121152
- Changed the way to provide publishableKey (
122-
- You need to add `HyperTrackPublishableKey` `meta-data` item to your `AndroidManifest.xml` and
123-
the same entry to `Info.plist`)
153+
- You need to add `HyperTrackPublishableKey` `meta-data` item to your `AndroidManifest.xml` and
154+
the same entry to `Info.plist`)
124155
- Renamed HyperTrackError types:
125-
- `gpsSignalLost` to `locationSignalLost`
126-
- `locationPermissionsDenied` to `permissionsLocationDenied`
127-
- `locationPermissionsInsufficientForBackground`
128-
to `permissionsLocationInsufficientForBackground`
129-
- `locationPermissionsNotDetermined` to `permissionsLocationNotDetermined`
130-
- `locationPermissionsProvisional` to `locationPermissionsProvisional`
131-
- `locationPermissionsReducedAccuracy` to `permissionsLocationReducedAccuracy`
132-
- `locationPermissionsRestricted` to `permissionsLocationRestricted`
156+
- `gpsSignalLost` to `locationSignalLost`
157+
- `locationPermissionsDenied` to `permissionsLocationDenied`
158+
- `locationPermissionsInsufficientForBackground`
159+
to `permissionsLocationInsufficientForBackground`
160+
- `locationPermissionsNotDetermined` to `permissionsLocationNotDetermined`
161+
- `locationPermissionsProvisional` to `locationPermissionsProvisional`
162+
- `locationPermissionsReducedAccuracy` to `permissionsLocationReducedAccuracy`
163+
- `locationPermissionsRestricted` to `permissionsLocationRestricted`
133164
- Renamed `setAvailability()` to `setIsAvailable(boolean)`
134165
- Changed `startTracking()` and `stopTracking()` to `setIsTracking(boolean)`
135166
- Renamed `onTrackingChanged` to `isTrackingSubscription`
@@ -142,11 +173,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
142173
- `initialize()` method (the API is now static)
143174
- Motion Activity permissions are not required for tracking anymore
144175
- HyperTrackError types:
145-
- `motionActivityPermissionsDenied`
146-
- `motionActivityServicesDisabled`
147-
- `motionActivityServicesUnavailable`
148-
- `motionActivityPermissionsRestricted`
149-
- `networkConnectionUnavailable`
176+
- `motionActivityPermissionsDenied`
177+
- `motionActivityServicesDisabled`
178+
- `motionActivityServicesUnavailable`
179+
- `motionActivityPermissionsRestricted`
180+
- `networkConnectionUnavailable`
150181
- `sync()` method
151182

152183
## [1.1.3] - 2023-06-16
@@ -199,9 +230,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
199230
### Added
200231

201232
- `initialize()` configuration params for
202-
- Debug logging
203-
- Background location permissions request for Android
204-
- Mock locations
233+
- Debug logging
234+
- Background location permissions request for Android
235+
- Mock locations
205236
- `onAvailabilityChanged` stream
206237
- `onError` stream
207238
- Location result for `addGeotag`
@@ -338,38 +369,75 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
338369
- Initial release.
339370

340371
[0.1.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.0
372+
341373
[0.1.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.1
374+
342375
[0.1.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.2
376+
343377
[0.1.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.3
378+
344379
[0.1.4]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.4
380+
345381
[0.1.5]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.5
382+
346383
[0.1.6]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.6
384+
347385
[0.1.7]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.7
386+
348387
[0.1.8]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.8
388+
349389
[0.1.9]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.1.9
390+
350391
[0.2.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.2.0
392+
351393
[0.2.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.2.1
394+
352395
[0.3.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.3.0
396+
353397
[0.3.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.3.1
398+
354399
[0.4.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.4.0
400+
355401
[0.4.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.4.1
402+
356403
[0.4.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.4.2
404+
357405
[0.4.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/0.4.3
406+
358407
[1.0.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/1.0.0
408+
359409
[1.1.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/1.1.0
410+
360411
[1.1.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/1.1.1
412+
361413
[1.1.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/1.1.2
414+
362415
[1.1.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/1.1.3
416+
363417
[2.0.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.0
418+
364419
[2.0.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.1
420+
365421
[2.0.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.2
422+
366423
[2.0.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.3
424+
367425
[2.0.4]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.0.4
426+
368427
[2.1.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.1.0
428+
369429
[2.1.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.1.1
430+
370431
[2.1.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.1.2
432+
371433
[2.2.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.0
434+
372435
[2.2.1]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.1
436+
373437
[2.2.2]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.2
438+
374439
[2.2.3]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.2.3
440+
375441
[2.3.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.3.0
442+
443+
[2.4.0]: https://github.com/hypertrack/sdk-flutter/releases/tag/2.4.0

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ android {
4343
disable 'InvalidPackage'
4444
}
4545
dependencies {
46-
def hyperTrackVersion = "7.6.0"
46+
def hyperTrackVersion = "7.7.0"
4747
implementation "com.hypertrack:sdk-android:${hyperTrackVersion}"
4848
implementation "com.hypertrack:location-services-google:${hyperTrackVersion}"
4949
implementation "com.hypertrack:push-service-firebase:${hyperTrackVersion}"

android/src/main/kotlin/com/hypertrack/sdk/flutter/HyperTrackPlugin.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.hypertrack.sdk.flutter.common.Serialization.serializeIsAvailable
88
import com.hypertrack.sdk.flutter.common.Serialization.serializeIsTracking
99
import com.hypertrack.sdk.flutter.common.Serialization.serializeLocateResult
1010
import com.hypertrack.sdk.flutter.common.Serialization.serializeLocationResult
11+
import com.hypertrack.sdk.flutter.common.Serialization.serializeOrders
1112
import com.hypertrack.sdk.flutter.common.Success
1213
import com.hypertrack.sdk.flutter.common.WrapperResult
1314
import io.flutter.embedding.engine.plugins.FlutterPlugin
@@ -31,12 +32,14 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
3132
private var isAvailableEventChannel: EventChannel? = null
3233
private var locateEventChannel: EventChannel? = null
3334
private var locationEventChannel: EventChannel? = null
35+
private var ordersEventChannel: EventChannel? = null
3436

3537
private var errorsCancellable: HyperTrack.Cancellable? = null
3638
private var isTrackingCancellable: HyperTrack.Cancellable? = null
3739
private var isAvailableCancellable: HyperTrack.Cancellable? = null
3840
private var locateCancellable: HyperTrack.Cancellable? = null
3941
private var locationCancellable: HyperTrack.Cancellable? = null
42+
private var ordersCancellable: HyperTrack.Cancellable? = null
4043

4144
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
4245
val messenger = flutterPluginBinding.binaryMessenger
@@ -54,18 +57,21 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
5457
isAvailableCancellable?.cancel()
5558
locateCancellable?.cancel()
5659
locationCancellable?.cancel()
60+
ordersCancellable?.cancel()
5761

5862
errorsEventChannel?.setStreamHandler(null)
5963
isTrackingEventChannel?.setStreamHandler(null)
6064
isAvailableEventChannel?.setStreamHandler(null)
6165
locateEventChannel?.setStreamHandler(null)
6266
locationEventChannel?.setStreamHandler(null)
67+
ordersEventChannel?.setStreamHandler(null)
6368

6469
errorsEventChannel = null
6570
isTrackingEventChannel = null
6671
isAvailableEventChannel = null
6772
locateEventChannel = null
6873
locationEventChannel = null
74+
ordersEventChannel = null
6975
}
7076

7177
override fun onMethodCall(
@@ -124,6 +130,10 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
124130
HyperTrackSdkWrapper.getName()
125131
}
126132

133+
SdkMethod.getOrders -> {
134+
HyperTrackSdkWrapper.getOrders()
135+
}
136+
127137
SdkMethod.getWorkerHandle -> {
128138
HyperTrackSdkWrapper.getWorkerHandle()
129139
}
@@ -295,6 +305,29 @@ public class HyperTrackPlugin : FlutterPlugin, MethodCallHandler {
295305
}
296306
},
297307
)
308+
309+
ordersEventChannel = EventChannel(messenger, "$PREFIX/orders")
310+
ordersEventChannel?.setStreamHandler(
311+
object : StreamHandler {
312+
override fun onListen(
313+
arguments: Any?,
314+
events: EventSink,
315+
) {
316+
WrapperResult
317+
.tryAsResult {
318+
ordersCancellable =
319+
HyperTrack.subscribeToOrders { orders ->
320+
events.success(serializeOrders(orders.values))
321+
}
322+
}.crashAppIfError()
323+
}
324+
325+
override fun onCancel(arguments: Any?) {
326+
ordersCancellable?.cancel()
327+
ordersCancellable = null
328+
}
329+
},
330+
)
298331
}
299332

300333
companion object {

android/src/main/kotlin/com/hypertrack/sdk/flutter/common/HyperTrackSdkWrapper.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.hypertrack.sdk.flutter.common.Serialization.serializeLocationSuccess
2121
import com.hypertrack.sdk.flutter.common.Serialization.serializeLocationWithDeviationSuccess
2222
import com.hypertrack.sdk.flutter.common.Serialization.serializeMetadata
2323
import com.hypertrack.sdk.flutter.common.Serialization.serializeName
24+
import com.hypertrack.sdk.flutter.common.Serialization.serializeOrders
2425
import com.hypertrack.sdk.flutter.common.Serialization.serializeWorkerHandle
2526

2627
typealias Serialized = Map<String, Any?>
@@ -139,6 +140,12 @@ internal object HyperTrackSdkWrapper {
139140
)
140141
}
141142

143+
fun getOrders(): WrapperResult<Serialized> {
144+
return Success(
145+
serializeOrders(HyperTrack.orders.values),
146+
)
147+
}
148+
142149
fun getWorkerHandle(): WrapperResult<Serialized> {
143150
return Success(
144151
serializeWorkerHandle(HyperTrack.workerHandle),

0 commit comments

Comments
 (0)