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
  • Manually initialize the SDK
  • Check your configuration
  • Check if user is authenticated
  • Logging
  • Listen for permissions and sensors status changes
  • DKDeviceConfigurationDelegate
  • Add a delegate
  • Remove a delegate
  • Remove all delegates
  • DKDeviceConfigurationEvent
  • DKDeviceConfigurationEventType
  • Get user’s information
  • Update user’s information
  • Update UserId
  • Account deletion
  • Retrieving the installation identifier
  • Reset

Was this helpful?

Export as PDF
  1. Get started with drivekit
  2. iOS

Advanced configurations

Manually initialize the SDK

By default, the DriveKit SDK is automatically initialized as soon as you add the TripAnalysis module to your project.

In some cases, you may want to manually initialize the SDK. To do this, you have to disable the automatic initialization by adding the key DKAutoInitEnabled associated to the Boolean value false into the Info.plist file:

<key>DKAutoInitEnabled</key>
<false/>

Then, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate.

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

The DriveKit modules include a method initialize that must be called in didFinishLaunchingWithOptions method of your AppDelegate if you have decided to manually initialize the SDK.

Check your configuration

You can check if DriveKit is well configured with the following method:

func isConfigured() -> Bool

This method returns true if these three conditions are met:

  • DriveKit Core is initialized

  • an API key is set

  • a userId is set

Check if user is authenticated

You can check if the user is connected by calling the following method:

func isUserConnected() -> Bool

This method returns true if the user is authenticated to DriveKit.

Logging

DriveKit comes with a logging feature that is enabled by default. This feature allows you to quickly identify the cause of a problem. We recommend leaving the log enabled as it does not consume memory space and is useful in the support phase. However, if you don't want to use it, it can be disabled.

Log will be written in app directory. One log file per month will be written with the name log-<YEAR>-<MONTH>.txt (example: log-2019-8.txt). All DriveKit modules log in this file. You can get a zip file with the log files of the previous month and the current one with the method DriveKitLog.shared.getZippedLogFilesUrl(), or by clicking on “Contact support” and changing the email receiver. The file will be in attachment of the email.

To be able to access logs from Files app, you must add the following entries in your Info.plist file: UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace, setting both to true.

Disable logging by calling the following method:

func disableLogging(showInConsole: Bool = true)

To activate logging, call the following method:

func enableLogging(showInConsole: Bool = true)

Listen for permissions and sensors status changes

If the user disables the sensors or revokes permissions, the application would not be able to detect and record a trip. To avoid this, the SDK identifies important sensor state and permission changes.

These events are shared and you can use them in your application to inform the user via a visual alert or by displaying a notification.

Event changes callbacks may not be fired in real time due to technical restrictions of iOS.

DKDeviceConfigurationDelegate

DKDeviceConfigurationDelegate is a protocol used to get callbacks when device configuration changes are detected:

protocol DKDeviceConfigurationDelegate: AnyObject {
    func deviceConfigurationDidChange(event: DKDeviceConfigurationEvent)
}

Add a delegate

func addDeviceConfigurationDelegate(_ delegate: DKDeviceConfigurationDelegate)

Remove a delegate

To remove a specific delegate, call the following method:

func removeDeviceConfigurationDelegate(_ delegate: DKDeviceConfigurationDelegate)

Remove all delegates

To remove all delegates, call the following method:

func removeAllDeviceConfigurationDelegates()

DKDeviceConfigurationEvent

DKDeviceConfigurationEvent is a class describing a device configuration event.

class DKDeviceConfigurationEvent {
    let type: DKDeviceConfigurationEventType
    let isValid: Bool
}
Attribute
Type
Description

type

Enum

isValid

Boolean

Boolean describing whether the device configuration event is valid or not

DKDeviceConfigurationEventType

public enum DKDeviceConfigurationEventType {
    case activityPermission
    case locationPermission
    case bluetoothPermission
    case notificationPermission
    case lowPowerMode
    case locationSensor
    case bluetoothSensor
}

Possible types are:

Event type
Description

activityPermission

Motion & Fitness permission status changed

locationPermission

Location permission status changed

bluetoothPermission

Bluetooth permission status changed

notificationPermission

Notifications permission status changed

lowPowerMode

Low Power Mode status changed

locationSensor

Location sensor status changed

bluetoothSensor

Bluetooth sensor status changed

The DriveKit SDK will run optimally if the isValid value of each event is true. The table below explains the impact of a status that is not true.

Event
Criticality
Consequence if value is false

LocationPermission

🔴

No trip recording if app has no access to GPS sensor

BluetoothPermission

🟡

No trip detection based on Bluetooth system

ActivityPermission

🟡

Detected transportation mode mode can be inaccurate when no access to this permission

NotificationPermission

🟢

Your application cannot send notification to the user if the permission is revoked.

lowPowerMode

🟢

No considerable impact

LocationSensor

🔴

No trip recording if GPS sensor is disabled

BluetoothSensor

🟡

No trip detection based on Bluetooth system. Can also impact beacon trip detection.

Get user’s information

To get user’s information (first name, last name and pseudo), call the getUserInfo method. It will retrieve and save these data locally:

DriveKit.shared.getUserInfo(synchronizationType: .defaultSync) { status, userInfo in
    if status == .success {
        // Get user's names in userInfo object.
    }
}

Update user’s information

You can add information to a user's account such as first name, last name and pseudo. These details are optional and you can choose to make the user's account anonymous. To update the user's information, you must call the updateUserInfo method:

DriveKit.shared.updateUserInfo(pseudo: "New_pseudo") { success in
    if success {
        // The pseudo has been successfully updated.
    }
}

Or to update all information:

DriveKit.shared.updateUserInfo(firstname: "New_firstname", lastname: "New_lastname", pseudo: "New_pseudo") { success in
    if success {
        // The firstname, lastname and pseudo have been successfully updated.
    }
}

Update UserId

It is possible to update the userId by calling the following method:

func updateUserId(userId: String)

Account deletion

You can delete a driver's account in DriveKit. This action deletes all the data related to the account.

The deletion can be done instantly or with delay.

  • In the first case, when the method is called, the account is instantly deleted.

  • In the second case, the driver has 30 days to log back into the application and reactivate his account.

To delete a driver's account, use the following method:

func deleteAccount(instantDeletion: Bool = false)

instantDeletion can have 2 values:

  • false : Default value, allows the user to recover the deleted account by logging-in again with the same credentials. Users have 30 days starting from the day when the account was deleted.

  • true : Allow to delete an account instantly. The account and all the related data will be immediately deleted and no rollback is possible.

Your team needs to have the deletion feature activated to use this method. Please contact DriveQuant if you need it.

You should restore the DriveKit API key in the onAccountDeleted() callback only when the status value is SUCCESS.

Retrieving the installation identifier

The installation identifier (installationId) is not a unique device identifier. It is used to identify an app installation that includes the DriveKit SDK, linked to a specific account on a particular device.

The installationId is generated based on the following attributes:

  • Installation date

  • App

  • User account

  • Device type

The installationId helps determine whether a user has logged into a mobile app with the same account across multiple devices.

For a user with one account and a single device, the installationId behaves as follows:

  • It remains unchanged if the user logs out and logs back in, as long as the app is not uninstalled.

  • It is updated when the user uninstalls and reinstalls the app.

If a user logs into the app on several devices using the same account, each device will have a different installationId.

If the user reconnects to the app on the same device but with a different account, the installationId will be updated.

The installationId uses the UUID format. Example: 123e4567-e89b-12d3-a456-426614174000

You can retrieve the installationId by calling the following computed property:

var installationId: String?

The returned installationId will be nil as long as the user is not authenticated to DriveKit.

Reset

If you need to reset DriveKit configuration (user logout for example), you can call the following method:

DriveKit.shared.reset()

All data saved locally will be erased and default configuration for every module will be restored.

PreviousQuick startNextReferences

Last updated 23 days ago

Was this helpful?

You can also make files of your application (including DriveKit log files) available in the by adding these 2 keys to your project's Info.plist file: UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace, setting them both to true.

To add a delegate and listen for , you can call the following function:

enum describing the type of event

To be able to check whenever userId got updated and catch the update status, you have to use delegate.

To be able to check whenever the account deletion is complete, you have to use the interface.

For example, you can retrieve the identifier after the driveKitDidConnect() callback is triggered. (Read more about the )

iOS Files app
DriveKitDelegate
Device Configuration Events
DKDeviceConfigurationEventType
DriveKitDelegate
DriveKitDelegate