@@ -13,6 +13,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313 - To learn more about how to best use this new feature see our guide
1414 here: [ Verify shift presence before starting work] ( https://developer.hypertrack.com/docs/clock-in-out-tagging#verify-shift-presence-before-starting-work )
1515
16+ ``` dart
17+ // check worker presence synchronously
18+ var activeOrders = await HyperTrack.orders;
19+ Order? currentOrder = activeOrders["current_order"];
20+ if (currentOrder != null) {
21+ handlePresence(currentOrder.isInsideGeofence);
22+ } else {
23+ print("'current_order' not found");
24+ }
25+
26+ // or subscribe to the changes in orders to get the status updates
27+ HyperTrack.ordersSubscription.listen((orders) {
28+ Order? currentOrder = orders["current_order"];
29+ if (currentOrder != null) {
30+ handlePresence(currentOrder.isInsideGeofence);
31+ } else {
32+ print("'current_order' not found");
33+ }
34+ });
35+
36+ // handle worker presence inside the order destination geofence
37+ void handlePresence(Result<bool, LocationError> isInsideGeofence) {
38+ switch (isInsideGeofence.runtimeType) {
39+ case Success:
40+ if ((isInsideGeofence as Success).value) {
41+ // allow worker to clock in for the shift
42+ } else {
43+ // "to clock in you must be at order destination"
44+ }
45+ break;
46+ case Failure:
47+ // resolve errors to check for presence
48+ break;
49+ }
50+ }
51+ ```
52+
1653### Changed
1754
1855- Updated HyperTrack SDK iOS to [ 5.7.0] ( https://github.com/hypertrack/sdk-ios/releases/tag/5.7.0 )
0 commit comments