Get started

Prerequisite

Before starting DriveKit Driver Data UI integration, make sure that you have initialized DriverData and Common UI components, especially if you have disabled the SDK auto-initialization.

Integration

Get the framework

The Driver Data UI SDK is available on Cocoapods master repo.

To access the framework in the repository, add the following lines to your Podfile:

target 'my-target' do
  pod 'DriveKitDriverDataUI'
end

Then, run pod install.

On this Github repository, you also have a demo app and source code of Driver Data UI that you can use as an example.

Initialization

If you have disabled the SDK auto-initialization, the Driver Data UI module must also be manually initialized. In the application's AppDelegate file, import DriveKitDriverDataUI:

import DriveKitDriverDataUI

Then, to initialize Driver Data UI SDK in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate:

import DriveKitCore
import DriveKitCommonUI
import DriveKitDriverData
import DriveKitDriverDataUI

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    DriveKit.shared.initialize()
    DriveKitDriverData.shared.initialize()
    DriveKitUI.shared.initialize()
    DriveKitDriverDataUI.shared.initialize()
    ...    
}

Override colors and texts

To override colors and texts in Driver Data UI SDK, see Common UI configuration.

Trip list main theme

It is possible to choose the main theme for the trip list. The main theme of the trip list is used to select the score to be displayed on the left side of the trip list. It is set by the TripData enum. It has 6 possible values:

  • .safety : The driving safety score.

  • .ecoDriving : The eco-driving score.

  • .distraction : The driving distraction score.

  • .distance : The trip distance.

  • .duration : The driving duration.

  • .speeding : The speeding score.

The value .speeding can be set only if this configuration is enabled for your API key.

The main theme is configured in the SDK initialize method by setting the parameter tripData.

DriveKitDriverDataUI.shared.initialize(tripData: .safety)

The default value is safety.

Trip map items

A trip is analyzed through several dimensions and DriveQuant's services provide multiple categories of scores. Depending on your need, you can highlight the scores of interest and hide some of them. The configuration of the trip detail screen allows to choose the displayed themes and the displaying order. To switch from one theme to another, simply swipe the bottom part of the screen or click on one of the pictograms in the navigation bar at the top of the screen.

The screens that can be displayed are listed below:

  • The safety analysis results: .safety.

  • The eco-driving results: .ecoDriving.

  • The distracted driving results: .distraction.

  • The speeding driving results: .speeding.

  • A scrollable list that displays all the events that occurred during the trip: .interactiveMap.

  • Synthetic data of the trip as average speed, CO2 emissions, estimated fuel consumption, driving conditions : .synthesis.

The value .speeding can be set only if this configuration is activated on your team.

The main theme is configured in the SDK initialize method by setting the parameter mapItems.

DriveKitDriverDataUI.shared.initialize(mapItems: [.safety, .ecoDriving, .distraction, .speeding, .interactiveMap, .synthesis])

The default value is:

[.safety, .ecoDriving, .distraction, .speeding, .interactiveMap, .synthesis]

The order in which the screens are displayed corresponds to the order of the items in the table. To hide a theme, simply do not add it to the table.

Display view in navigation controller

To show view in your navigation controller, you just have to create an instance of TripListVC and then push the view controller in your navigation controller.

let tripListVC = TripListVC()
self.navigationController?.pushViewController(tripListVC, animated: true)

Last updated