Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sgusakovsky committed Apr 24, 2024
1 parent 89cce71 commit 5f2d117
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 3 deletions.
182 changes: 181 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,24 @@ add network permissions
import com.telematicssdk.TelematicsSDKApp

class App: TelematicsSDKApp() {
//...

override fun onCreate() {
val api = TrackingApi.getInstance()
api.initialize(this, setTelematicsSettings())
super.onCreate()
}

override fun setTelematicsSettings(): Settings {
val settings = Settings(
stopTrackingTimeout = Settings.stopTrackingTimeHigh,
accuracy = Settings.accuracyHigh,
autoStartOn = true,
elmOn = false,
hfOn = true
)
return settings
}
}
```

2. add to tag __application__ of file ./app/src/main/AndroidManifest.xml this class __name__:
Expand Down Expand Up @@ -113,6 +129,170 @@ Starting from iOS version 15 and above, as well as Flutter 2.0.6, modification o
You must request permissions for the application before GeneratedPluginRegistrant
[Example AppDelegate.swift](https://github.com/Mobile-Telematics/telematicsSDK-demoapp-flutter-/blob/main/example/ios/Runner/AppDelegate.swift)
### Enabling and Disabling the SDK
Firstly, create trackingAPI object to interact with SDK
``` dart
import 'package:telematics_sdk/telematics_sdk.dart';
final _trackingApi = TrackingApi();
```
**Login**
``` dart
await _trackingApi.setDeviceID(deviceId: "DEVICE_TOKEN");
```
**Logout**
``` dart
await _trackingApi.clearDeviceID();
```
**Enable the SDK**
``` dart
await _trackingApi.setEnableSdk(enable: true);
```
**Disable the SDK**
``` dart
await _trackingApi.setEnableSdk(enable: false);
```
**Disable the SDK with force uploading data**
``` dart
await _trackingApi.setDisableWithUpload();
```
### Available Methods
**Manual start tracking**
``` dart
await _trackingApi.startManualTracking();
```
**Manual stop tracking**
``` dart
await _trackingApi.stopManualTracking();
```
**Permissions status**
``` dart
final isAllGranted = await _trackingApi.isAllRequiredPermissionsAndSensorsGranted();
```
**Tracking status**
``` dart
final isTracking = await _trackingApi.isTracking();
```
**Enable high-frequency data collection (HF)**
We strongly recommend keeping it enabled by default
``` dart
await _trackingApi.enableHF(value: true);
```
**Create new tag**
The detailed information about using Tags is available [here](https://docs.damoov.com/docs/ios-sdk-incoming-tags)
``` dart
String tag = 'TAG';
String source = 'App';
await _trackingApi.addFutureTrackTag(tag: tag, source: source);
```
**Remove a tag**
``` dart
String tag = 'TAG';
await _trackingApi.removeFutureTrackTag(tag: tag);
```
**Remove all tags**
``` dart
String tag = 'TAG';
await _trackingApi.removeAllFutureTrackTags();
```
**Setting up the permission wizard**
Without these permissions SDK can not be enabled.
If you want to use your own way to request permissions, you can skip this part.
To show the permission wizard, follow next steps:
1. Create and init **StreamSubscription** in your widget
``` dart
late StreamSubscription<PermissionWizardResult?> _onPermissionWizardStateChanged;
@override
void initState() {
_onPermissionWizardStateChanged = _trackingApi
.onPermissionWizardClose
.listen(_onPermissionWizardResult);
void _onPermissionWizardResult(PermissionWizardResult result) {
if (result == PermissionWizardResult.allGranted) {
//All permissions are granted. To do something here.
} else {
//Permissions are not granted. To do something here.
}
}
```
2. Request to show the permission wizard
``` dart
await _trackingApi.showPermissionWizard(
enableAggressivePermissionsWizard: false,
enableAggressivePermissionsWizardPage: true
);
```
If `[enableAggressivePermissionsWizard]` set to `true` the wizard will be finished if all required permissions granted (user can’t cancel it with back button), otherwise if set to `false` the wizard can be finished with not all granted permissions or cancelled with back button.
If `[enableAggressivePermissionsWizardPage]` set to `true` the wizard will slide to next page if requested permissions granted on current page, otherwise if set to `false` the wizard can slide with not granted permissions.
### Available Methods (iOS only)
**Enable/Disable Automatic tracking**
``` dart
bool disableTracking = false;
//true to disable automatic tracking (tracking is enabled by default)
await _trackingApi.setDisableTracking(value: disableTracking);
```
**Automatic tracking status**
``` dart
final isTrackingDisabled = await _trackingApi.isDisableTracking();
```
**Enable/Disable Aggressive Heartbeats**
The telematics SDK (iOS only) supports two operational modes for heartbeats;
**Aggressive heartbeats** - heartbeats are sent every 20 minutes. SDK is always active.
**Normal Heartbeats** - heartbeats are sent every 20 minutes but when SDK turns into Standby mode, it will be activated only by a new trip, and heartbeat will be sent respectively.
**Mode switcher**
``` dart
bool enable = true; //false to disable aggressive heartbeats
await _trackingApi.setAggressiveHeartbeats(value: enable)
```
**Check state**
``` dart
final isAggressiveHeartbeats = await _trackingApi.isAggressiveHeartbeat()
```
**Enable Accidents detection**
Accidents detection is disabled by default. You can enable detection.
In order for accidents detection to work, you need to [enable high-frequency data collection](https://docs.damoov.com/docs/methods-for-ios-app#enable-high-frequency-data-collection-hf)
``` dart
await _trackingApi.enableAccidents(value: true);
//to check current accidents status
final isEnabledAccidents = await _trackingApi.isEnabledAccidents();
```
## Links
[https://damoov.com](https://damoov.com/)
2 changes: 2 additions & 0 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package example.android

buildscript {
ext.kotlin_version = '1.9.0'
repositories {
Expand Down
1 change: 0 additions & 1 deletion lib/src/tracking_api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:ffi';

import 'package:flutter/services.dart';
import 'package:telematics_sdk/src/data/api_language.dart';
Expand Down
1 change: 0 additions & 1 deletion test/native_call_handler_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:telematics_sdk/telematics_sdk.dart';
import 'package:telematics_sdk/src/native_call_handler.dart';
import 'package:telematics_sdk/src/data/permission_wizard_result.dart';

void main() {
group('NativeCallHandler', () {
Expand Down

0 comments on commit 5f2d117

Please sign in to comment.