Coder Social home page Coder Social logo

mobile-telematics / telematicssdk-demoapp-flutter- Goto Github PK

View Code? Open in Web Editor NEW
21.0 6.0 12.0 180 KB

Demo telematics app for Flutter. The application walks you through the telematics SDK integration. The technology is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications

Home Page: https://www.damoov.com/telematics-sdk/

License: Other

Kotlin 14.04% Ruby 2.41% Swift 25.98% Objective-C 0.38% Dart 57.19%
telematics-sdk flutter telemetry-collection telematics telemetry-server road-safety-tips road-safety driving-style vehicle-tracking driving-scorecard

telematicssdk-demoapp-flutter-'s Introduction

Telematics SDK

A flutter plugin for tracking the person's driving behavior such as speeding, turning, braking and several other things on iOS and Android.

Disclaimer: This project uses Telematics SDK which belongs to DAMOOV PTE. LTD.
When using Telematics SDK refer to these terms of use

Getting Started

Initial app setup & credentials

For commercial use, you need create a developer workspace in DataHub and get InstanceId and InstanceKey auth keys to work with our API.

Android

Please draw attention that Android SDK supports Gradle 8+ versions only.

AndroidManifest.xml

add to file ./app/src/main/AndroidManifest.xml props:

  1. 'xmlns:tools="http://schemas.android.com/tools"' into manifest tag
  2. 'tools:replace="android:label"' into __application tag

as shown below:

<manifest
    xmlns:tools="http://schemas.android.com/tools">
    <application
        tools:replace="android:label,android:name">
        ...
    </application>
    ...
</manifest>

add network permissions

<manifest>
...
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
...

build.gradle

add to file (module)/build.gradle props:

    android {
    ...
        buildTypes {
            release {
                ...
                shrinkResources false
                minifyEnabled false
                ...
            }
        }
    ...
    }

Proguard

-keep public class com.raxeltelematics.** {*;}

Android Advanced

SetTrackingSettings

  1. Override application class extends TelematicsSDKApp

    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
    }

} ```

  1. add to tag application of file ./app/src/main/AndroidManifest.xml this class name:

    <application
            android:name=".App">
        ...
    </application>
    
  2. add Telematics SDK repository into (module)/build.gradle

    dependencies {
        //...
        implementation "com.telematicssdk:tracking:2.2.262"
    }

iOS

Add permissions in your project's ios/Runner/Info.plist:

    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>location</string>
        <string>remote-notification</string>
    </array>
    <key>NSMotionUsageDescription</key>
    <string>Please, provide permissions for this Demo</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Please, provide permissions for this Demo</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Please, provide permissions for this Demo</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Please, provide permissions for this Demo</string>
    <key>BGTaskSchedulerPermittedIdentifiers</key>
    <array>
        <string>sdk.damoov.apprefreshtaskid</string>
        <string>sdk.damoov.appprocessingtaskid</string>
    </array>

Starting from iOS version 15 and above, as well as Flutter 2.0.6, modification of ios/Runner/AppDelegate.swift is required You must request permissions for the application before GeneratedPluginRegistrant Example AppDelegate.swift

Enabling and Disabling the SDK

Firstly, create trackingAPI object to interact with SDK

import 'package:telematics_sdk/telematics_sdk.dart';

final _trackingApi = TrackingApi();

Login

    await _trackingApi.setDeviceID(deviceId: "DEVICE_TOKEN");

Logout

    await _trackingApi.clearDeviceID();

Enable the SDK

    await _trackingApi.setEnableSdk(enable: true);

Disable the SDK

    await _trackingApi.setEnableSdk(enable: false);

Disable the SDK with force uploading data

    await _trackingApi.setDisableWithUpload();

Available Methods

Manual start tracking

    await _trackingApi.startManualTracking();

Manual stop tracking

    await _trackingApi.stopManualTracking();

Permissions status

    final isAllGranted = await _trackingApi.isAllRequiredPermissionsAndSensorsGranted();

Tracking status

    final isTracking = await _trackingApi.isTracking();

Enable high-frequency data collection (HF) We strongly recommend keeping it enabled by default

    await _trackingApi.enableHF(value: true);

Create new tag The detailed information about using Tags is available here

    String tag = 'TAG';
    String source = 'App';
    await _trackingApi.addFutureTrackTag(tag: tag, source: source);

Remove a tag

    String tag = 'TAG';
    await _trackingApi.removeFutureTrackTag(tag: tag);

Remove all tags

    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
    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.
        }
    }
  1. Request to show the permission wizard
    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

    bool disableTracking = false;
    //true to disable automatic tracking (tracking is enabled by default)
    await _trackingApi.setDisableTracking(value: disableTracking);

Automatic tracking status

    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

    bool enable = true; //false to disable aggressive heartbeats
    await _trackingApi.setAggressiveHeartbeats(value: enable)

Check state

    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

    await _trackingApi.enableAccidents(value: true);
    
    //to check current accidents status
    final isEnabledAccidents = await _trackingApi.isEnabledAccidents();

Links

https://damoov.com

telematicssdk-demoapp-flutter-'s People

Contributors

alekseevaelena avatar bayernmfan avatar dkrutskikh avatar ishornikov avatar mpkander avatar sergeyiossdk avatar sgusakovsky avatar telematicsgig avatar vorobevsa avatar zangievm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

telematicssdk-demoapp-flutter-'s Issues

Android build error - Sealed classes are not supported as program classes

Hey guys, how are you? I'm trying to build your project, but I'm getting an error and I'd like your help. I have already made all the changes requested in the specifications, the only difference is that instead of using your wrapper I chose to take your SDK and place it in a folder called plugins. And now whenever I try to build this error I get this error:

Captura de Tela 2024-06-05 às 16 00 36

Here are some important settings from my project that you might want to see:

android/app/build.gradle

plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
id "com.google.firebase.crashlytics"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '28'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 34
namespace "com.mycompany.apps.myapp"

 compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

dependencies {
    implementation 'com.google.firebase:firebase-analytics:17.4.1'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.mycompany.apps.myapp"
    minSdkVersion 24
    targetSdkVersion 33
    versionCode flutterVersionCode.toInteger() + 1
    versionName flutterVersionName
}

signingConfigs {
        release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}



buildTypes {
    release {
        signingConfig signingConfigs.debug
        shrinkResources false
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
flavorDimensions "driverapp"
productFlavors {
    dev {
        dimension "myapp"
        applicationIdSuffix ".dev"
        resValue "string", "app_name", "My App"
        versionNameSuffix ".dev"
    }
    prod {
        dimension "myapp"
        applicationId "com.mycompany.apps.myapp"
        resValue "string", "app_name", "My App"
    }
}

}

flutter {
source '../..'
}

dependencies {
implementation "com.telematicssdk:tracking:2.2.260"
}

android/settings.gradle

pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}

}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
id "com.google.gms.google-services" version "4.4.0" apply false
id "com.google.firebase.crashlytics" version "2.9.9" apply false
}

include ":app"

gradle-wrapper.properties:

distributionUrl=https://services.gradle.org/distributions/gradle-7.6.3-all.zip

Modute compiLed with Swift 5.5.2 cannot be imported by the Swift 5.6

After failing to run on M1, I am trying to run an example project on an intel chip Macbook.
The example project shows different errors:

Uncategorized (Xcode): Command CompiteSwiftSources failed with a nonzero exit code

Swift Compiler Error (Xcode): Unable to Load standard Library for target 'arm64-appLe-ios10. 0"

Swift Compiter Error (Xcode): Modute compiLed with Swift 5.5.2 cannot be imported by the Swift 5.6 compiter: /Users/huynq/Downtoads/koLoi-gazeLLe-deve Lopment/ios/Pods/Rax
/Users/huyngq/.pub-cache/git/tetLematicsSDK-demoapp-f tutter-—cc5463f5b671d1d8c29fc050365a4ea5c51b448c/ios/CLasses/SwiftTeLematicsSDKPLugin. swift:1:7

Uncategorized (Xcode): Command EmitSwiftModute failed with a nonzero exit code

Couldn't build the application for the simulator.
Error launching application on iPhone 13.

image

Build project error

Hey :)
I have problem with building flutter example project.

Here is problems from console:

Launching lib/main.dart on iPhone 14 Pro in debug mode...
main.dart:1
Xcode build done. 6.3s
Failed to build iOS app
Swift Compiler Error (Xcode): Unable to load standard library for target 'arm64-apple-ios10.0'

Swift Compiler Error (Xcode): Module compiled with Swift 5.5.2 cannot be imported by the Swift 5.8.1 compiler: /Users/funkydevil/Downloads/telematicsSDK-demoapp-flutter--main/example/ios/Pods/RaxelPulse/RaxelPulse.framework/Modules/RaxelPulse.swiftmodule/arm64.swiftmodule
/Users/funkydevil/Downloads/telematicsSDK-demoapp-flutter--main/ios/Classes/SwiftTelematicsSDKPlugin.swift:1:7

Could not build the application for the simulator.
Error launching application on iPhone 14 Pro.
Exited

I was trying to make my own test project with telematics_sdk: ^0.1.1 dependence, but got same error

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.