LogoLogo
ProductsUse casesDocsSupport
  • Introducing DriveKit
  • DriveKit Guides
  • Get started with drivekit
    • Trip recording lifecycle
    • iOS
      • 🚀Quick start
      • Advanced configurations
      • References
      • iOS DriveKit Demo App
    • Android
      • 🚀Quick start
      • Advanced configurations
      • References
      • Android DriveKit Demo App
      • Android 15 Migration guide
      • Android 14 Migration guide
      • Troubleshooting
  • Trip analysis
    • Introduction
    • iOS
      • Permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (iOS)
    • Android
      • Runtime permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
      • Android
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
    • REST services
      • Trip
      • References
    • Trip Simulator
      • iOS
      • Android
  • PERMISSIONS UTILS
    • Introduction
    • User interface
      • iOS
        • Get started
        • Main configurations
      • Android
        • Get started
        • Main configurations
  • COMMON UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
    • References
  • DRIVER DATA
    • Introduction
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
      • Android
        • Get Started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
  • Driver Data Timeline UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • Vehicle
    • Introduction
    • iOS
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (iOS)
    • Android
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Main configurations
        • Advanced configurations
      • Android
        • Get started
        • Main configurations
        • Advanced configurations
  • DRIVER ACHIEVEMENT
    • Introduction
    • iOS
      • Get started
    • Android
      • Get Started
    • User interface
      • iOS
      • Android
  • CHALLENGE
    • Introduction
    • Important challenge rules
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
      • Android
        • Get started
  • GROUP
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • React Native
    • Get started
    • Integration
  • Flutter
    • Get started
    • Integration
  • Push services
    • Introduction
    • Push Trip Data
    • Push Deleted trip
    • Push Crash Data
    • Push Diagnosis Data
  • ADMIN SERVICES
    • Beacon
      • Add
      • Replace
      • Delete
      • Configuration
    • Challenges
      • List of challenges
      • Challenge details
      • Registered users
      • Challenge ranking
      • Users' progress
      • Definitions
    • Customer
      • Activity timeline
    • Driver
      • Timeline
      • Synthesis
      • Identity
      • Status
      • Add or update a metadata
      • Vehicles
      • Profile
      • Application diagnoses
    • Drivers
      • Account
      • Statistics
      • Ranking
      • Expired accounts
    • Group
      • Timeline
      • Synthesis
    • Trips
      • Add or update a metadata
      • Delete a metadata
    • Vehicle
      • Create
      • Characteristics
      • Configuration
      • Statistics
      • Update mileage
      • Tire and brake wear update
      • References
  • Crashes
    • Annotate a crash
    • Revoke crash location URL
  • ENTERPRISE SERVICES
    • Introduction
    • Teams
      • Create a team
      • List of teams
      • Enable or disable a team
    • Hyper-admins
      • Create a hyper-admin
      • List of hyper-admins
      • Delete a hyper-admin
    • Monitoring
      • Get a push trip data report
      • Get a push crash data report
      • Request to retry failed trips
      • Request to retry failed crashes
      • Get the status of a task
  • Release notes
    • Changelog
      • iOS
      • Android
      • UI iOS
      • UI Android
Powered by GitBook
On this page
  • Prerequisite
  • Integration
  • Get framework
  • Initialization
  • Get driver trips
  • Get specific trip
  • Get trip road data
  • Delete a trip
  • Get driver synthesis
  • Get driver timelines
  • Get driver profile

Was this helpful?

Export as PDF
  1. DRIVER DATA
  2. iOS

Get started

PreviousiOSNextReferences (iOS)

Last updated 3 months ago

Was this helpful?

Prerequisite

Before starting DriveKit Driver Data integration, make sure that you have .

If you use Driver Data without having initialized DriveKit, the SDK may not work properly in your application.

Integration

Get framework

The Driver Data SDK is available on Cocoapods master repo.

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

target 'my-target' do
  pod 'DriveKitDriverData'
end

Then, run pod install.

Initialization

If you have , an initialization phase is required to use the feature included in the Driver Data module. In the application's AppDelegate file, import DriveKitDriverData:

import DriveKitDriverDataModule

Then, to initialize Driver Data module in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate file.

import DriveKitCoreModule
import DriveKitTripAnalysisModule

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

Get driver trips

public func getTripsOrderByDateDesc(type: SynchronizationType = .defaultSync, completionHandler: @escaping (TripSyncStatus, [DKTrip]) -> ())

SynchronizationType can have 2 values:

  • defaultSync: if this value is used, the SDK will try to synchronize local trips with DriveQuant backend to get new trips or modified trips, and then return the trip list via the completionHandler.

  • cache: if this value is used, no synchronization will be performed and only trips previously synchronized will be returned via the completionHandler.

TripSyncStatus in the completionHandler can have 4 values:

  • noError: Synchronization has been successfully performed.

  • cacheDataOnly: SynchronizationType has been set to cache.

  • failedToSyncTripsCacheOnly: Synchronization has failed, only trips previously synchronized are returned.

  • syncAlreadyInProgress: A synchronization is in progress, only trips previously synchronized are returned until the synchronization is finished.

Trips are returned and sorted by end date in descending order.

If train trips have been recorded by Trip Analysis SDK, they won't be returned by this method.

Example:

DriveKitDriverData.shared.getTripsOrderByDateDesc(completionHandler: { status, trips in
    // Check status and use trips data
})

Get specific trip

public func getTrip(itinId: String, completionHandler: @escaping (TripSyncStatus, DKTrip?) -> ())

The itinId parameter is the unique identifier for a trip.

When you call this method, you will get trip data and trip safety events. If safety events are not synchronized locally for the trip, a synchronization with DriveQuant backend will be performed and then, the trip will be returned with safety events synchronized.

Example:

DriveKitDriverData.shared.getTrip(itinId: itinId, completionHandler: { status, trip in
    // Check status and use trip data
})

Get trip road data

To get road data of the trip (latitude, longitude), you have to call the following method:

public func getRoute(itinId: String, completionHandler: @escaping (DKRoute?) -> ())

If route value in completionHandler is nil , the synchronization has failed.

Example:

DriveKitDriverData.shared.getRoute(itinId: itinId, completionHandler: { route in
    if let route = route {
        // Use route data
     } else {
        // Failed to synchronize route
     }
})

Delete a trip

To delete a trip, you have to call the following method:

 public func deleteTrip(itinId: String, completionHandler: @escaping (Bool) -> ())

The itinId parameter is the unique identifier for a trip.

Example:

DriveKitDriverData.shared.deleteTrip(itinId: self.viewModel.itinId, completionHandler: { deleteSuccessful in
    if deleteSuccessful {
        // trip successfully deleted
    } else {
        // Failed to delete trip
    }
})

Get driver synthesis

To get driver synthesis data, you have to call the following method:

public func getSynthesis(type: SynchronizationType = .cache, completionHandler: @escaping (SynthesisSyncStatus, DKSynthesis?) -> ())

SynchronizationType can have 2 values:

  • defaultSync: if this value is used, the SDK will try to synchronize the driver synthesis data with DriveQuant backend and then return it via the completionHandler.

  • cache: if this value is used, no synchronization will be performed and the data retrieved during the last synchronisation will be returned via the completionHandler.

SynthesisSyncStatus in the completionHandler can take 3 values:

  • cacheDataOnly: SynchronizationType has been set to cache.

  • noError: Synchronization has been successfully performed.

  • failedToSyncSynthesisCacheOnly: Synchronization has failed, only data retrieved during the last synchronisation is returned.

Example:

import DriveKitDriverDataModule

DriveKitDriverData.shared.getSynthesis(type: .defaultSync) { status, synthesis in
    // Check status and use synthesis
}
public func getDriverTimelines(periods: [DKPeriod], type: SynchronizationType = .defaultSync, completionHandler: @escaping (TimelineSyncStatus, [DKDriverTimeline]?) -> Void)

periods attribute contains periods you are interested in: .week , .month and/or .year.

  • defaultSync: if this value is used, the SDK will try to synchronize timelines with DriveQuant backend and then return them via the completionHandler.

  • cache: if this value is used, no synchronization will be performed and the data retrieved during the last synchronisation will be returned via the completionHandler.

  • cacheDataOnly: SynchronizationType has been set to cache.

  • noError: Synchronization has been successfully performed.

  • failedToSyncTimelineCacheOnly: Synchronization has failed, only data retrieved during the last synchronisation are returned.

  • noTimelineYet: Synchronization has been successfully performed and there is currently no timeline.

import DriveKitDriverDataModule

DriveKitDriverData.shared.getTimelines(periods: [.week, .month], type: .defaultSync) { (status, timelines) in
    // Check status and use timelines
}

Get driver timelines

To get driver timelines, you have to call the following method:

public func getDriverTimelines(
    periods: [DKPeriod],
    ignoreItemsWithoutTripScored: Bool = false,
    type: SynchronizationType = .defaultSync,
    completionHandler: @escaping (TimelineSyncStatus, [DKDriverTimeline]?) -> Void
)

TimelineSyncStatus in the completionHandler can take 4 values:

  • cacheDataOnly: SynchronizationType has been set to cache.

  • noError: Synchronisation has been successfully performed.

  • failedToSyncTimelineCacheOnly: Synchronisation has failed, only data retrieved during the last synchronisation are returned.

  • noTimelineYet: Synchronisation has been successfully performed and there is currently no timeline.

Example:

import DriveKitDriverDataModule

DriveKitDriverData.shared.getDriverTimelines(periods: [.week, .month, .year], type: .defaultSync) { (status, timelines) in
    // Check status and use timelines
}

Get driver profile

To get driver profile, you have to call the following method:

public func getDriverProfile(
   type: SynchronizationType = .defaultSync,
   completionHandler: @escaping (DKDriverProfileStatus, DKDriverProfile?) -> Void
)

SynchronizationType can have 2 values:

  • defaultSync: if this value is used, the SDK will try to synchronize the driver profile with DriveQuant backend and then return it via the completionHandler.

  • cache: if this value is used, no synchronisation will be performed and the data retrieved during the last synchronisation will be returned via the completionHandler.

DKDriverProfileStatus in the completionHandler can take 4 values:

  • success: Synchronization type has been successfully performed.

  • failedToSyncDriverProfileCacheOnly: Synchronisation has failed, only data retrieved during the last synchronisation is returned.

  • noDriverProfileYet: Synchronisation has been successfully performed and there is currently no driver profile for this user.

  • forbiddenAccess: Your team doesn’t have access to this data.

import DriveKitDriverDataModule

DriveKitDriverData.shared.getDriverProfile(type: .defaultSync) { (status, driverProfile) in
    // Check status and use driverProfile
}

To get , you have to call the following method:

The second argument in the completionHandler is the list of objects.

To get a specific , you have to call the following method:

TripSyncStatus can have the same value as and the value failedToSyncSafetyEvents if the safety events synchronization failed.

The second argument in the completionHandler is the requested object, if exists.

The second argument in the completionHandler is a list of object, one per period requested.

The second argument in the completionHandler is the object requested.

above
initialized DriveKit
disabled the SDK auto-initialization
Driver trips
DKTrip
trip
Trip
DKDriverTimeline
DKDriverProfile