iOS

This section describes how to integrate DriveKit into an iOS mobile application.

Requirements

DriveKit is developed with the Swift 5 language and is compatible with iOS 10.0 and later versions.

Integration

DriveKit SDK are available on Github repository.

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

Podfile
target 'my-target' do
use_frameworks!
pod 'Networking', :git => 'https://github.com/DriveQuantPublic/drivekit-ios-sdk.git', :tag => '1.1.11'
pod 'DriveKitCore', :git => 'https://github.com/DriveQuantPublic/drivekit-ios-sdk.git', :tag => '1.1.11'
end

Be sure to always have the same tag for all DriveKit frameworks in your project.

Initialization

DriveKit initialization

To initialize DriveKit in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your application class.

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

All DriveKit modules have a method initialize that must be called in didFinishLaunchingWithOptions method of your AppDelegate file.

Add API key

To use DriveKit framework, you have to obtain an API Key from DriveQuant. If you don't have an API key, please contact DriveQuant

Once your API key is securely stored in your application, you can configure DriveKit by calling the following method.

Untitled
DriveKit.shared.setApiKey(key: "MyApiKey")

Identify user

Each driver must be identified with a unique identifier, once you have this identifier, configure DriveKit by calling the following method.

Untitled
DriveKit.shared.registerUser(userId: "MyUserId")

You can call these 2 configuration methods anywhere in your app's code. DriveKit will save the value locally. If the app is killed and relaunched, DriveKit will be reconfigured automatically.

DriveKit SDK will not work until you set the API key and the userId

Check your configuration

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

Untitled
DriveKit.shared.isConfigured()

This method return true if it is well configured.

Reset

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

Untitled
DriveKit.shared.reset()

All data saved locally by DriveKit will be erased.

All DriverKit frameworks have reset method that erased all data saved locally by the framework.

Be sure to call reset method of all frameworks to fully reset DriveKit configuration.

Logging

To ease integration, DriveKit provide a logging feature. To activate logging, call the following method.

Untitled
DriveKit.shared.enableLogging()

Log will be written in app directory. One log file per month will be written with the name log-<MONTH>-<YEAR>.txt (example : log-8-2019.txt). All DriveKit modules log in this file.

To write log files on user smartphone, you must add the following entry in your info.plist file UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace set to true .

Disable logging by calling

Untitled
DriveKit.shared.disableLogging()