Driving Insights
To learn about the Driving Insights feature, check out this page.
Prerequisites
The Driving Insights feature relies on additional library dependencies alongside the core SDK dependency. To start using this feature, you must first add these dependencies to you project.
Android
Open your app build.gradle file and add the driving insights dependency.
dependencies {
implementation(platform('com.sentiance:sdk-bom:<sentiance-version>'))
implementation('com.sentiance:sdk-driving-insights')
}Utilize the Driving Insights APIs
In this section, you can find examples of how to query the Sentiance SDK for driving insights, safe driving scores, detailed driving events. You will also find how to register to be notified of driving insights, once it becomes available.
Query for Driving Insights
Driving Insights become available a few minutes after a transport ends. Once the user stops driving, the SDK takes a few minutes to make sure that the drive is over, and then proceeds to prepare the insights.
To be notified of when the insights are ready, you can subscribe for Driving Insights updates.
To retrieve driving insights, use the getDrivingInsights method.
Query For Driving Events
The Sentiance SDK offers more granular driving insights. You can retrieve detailed events, such as speeding and harsh driving, as shown below.
Subscribe for Driving Insights Updates
Checkout Real-time Listeners to read more about implementing the SDK's Listeners
To get driving insights updates even when your app is in the background, place the following code inside your app's entrypoint index.js file. If you're only interested in these updates when your app is foregrounded, place this code inside the appropriate UI code instead.
Create a background.dart file under your project's lib folder with the following code:
Add the following code, depending on your target platform.
For iOS, add the following to your app delegate class:
For Android, add this code to your custom application class:
If you're calling other 3rd party plugin APIs inside your registerEventTimelineListener Dart function, then you need to register these plugins with the Sentiance SDK. See this for more details.
Last updated