Skip to content

Commit

Permalink
Update tracking api for ios and bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
sgusakovsky committed Jan 29, 2024
1 parent 6c7ab84 commit 1eaa3e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class TelematicsSDKPlugin : ActivityAware, ActivityResultListener, FlutterPlugin
"setDisableWithUpload" -> setDisableWithUpload(result)
"startManualTracking" -> startManualTracking(result)
"stopManualTracking" -> stopManualTracking(result)
"enableHF" -> enableHF(call, result)
"showPermissionWizard" -> showPermissionWizard(call, result)
"getTrackTags" -> getTrackTags(call, result)
"addTrackTags" -> addTrackTags(call, result)
Expand Down Expand Up @@ -160,6 +161,11 @@ class TelematicsSDKPlugin : ActivityAware, ActivityResultListener, FlutterPlugin
api.setEnableSdk(enable)
result.success(null)
}
private fun enableHF(call: MethodCall, result: Result) {
val enable = call.argument<Boolean?>("enableHF") as Boolean
api.setHfRecordingEnabled(enable)
result.success(null)
}

private fun setDisableWithUpload(result: Result) {
api.setDisableWithUpload()
Expand Down
25 changes: 13 additions & 12 deletions example/lib/title_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ class _TitleScreenState extends State<TitleScreen> {
_isAllRequiredPermissionsGranted =
await _trackingApi.isAllRequiredPermissionsAndSensorsGranted() ?? false;

final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
_isAggressiveHeartbeats = await _trackingApi.isAggressiveHeartbeat() ?? false;
if (Platform.isIOS) {
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
_isAggressiveHeartbeats = await _trackingApi.isAggressiveHeartbeat() ?? false;
}

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
Expand Down Expand Up @@ -221,15 +223,14 @@ class _TitleScreenState extends State<TitleScreen> {
} else {
await _trackingApi.setDeviceID(deviceId: _deviceId);
await _trackingApi.setEnableSdk(enable: true);
await _trackingApi.enableHF(value: true);

_isSdkEnabled = await _trackingApi.isSdkEnabled() ?? false;
if (Platform.isIOS) {
await _trackingApi.enableHF(value: true);
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
}

_isSdkEnabled = await _trackingApi.isSdkEnabled() ?? false;
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;

setState(() {});
}
}
Expand All @@ -243,9 +244,9 @@ class _TitleScreenState extends State<TitleScreen> {
if (_isTracking) {
if (Platform.isIOS) {
await _trackingApi.setDisableTracking(value: true);
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
}
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
}

await _trackingApi.setEnableSdk(enable: false);
Expand All @@ -262,9 +263,9 @@ class _TitleScreenState extends State<TitleScreen> {
if (_isTracking) {
if (Platform.isIOS) {
await _trackingApi.setDisableTracking(value: true);
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
}
final disableTracking = await _trackingApi.isDisableTracking() ?? false;
_isTracking = !disableTracking;
}

await _trackingApi.setDisableWithUpload();
Expand Down

0 comments on commit 1eaa3e5

Please sign in to comment.