Get started

Prerequisite

Before starting DriveKit Vehicle UI integration, make sure that you have initialized Vehicle and Common UI SDKs.

Integration

The Vehicle UI module is available on Cocoapods master repo.
1
target 'my-target' do
2
pod 'DriveKitVehicleUI'
3
end
Copied!
Then, run pod install.
On a Github repository, you can find a demo app and the source code of Vehicle UI that you can use as an example.

Initialization

An initialization phase is required to use the feature included in the Vehicle UI module. In the application's AppDelegate file, import DriveKitVehicleUI:
1
import DriveKitVehicleUI
Copied!
Then, to initialize Vehicle UI module in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate:
1
import DriveKitCore
2
import DriveKitCommonUI
3
import DriveKitVehicleUI
4
5
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
6
DriveKit.shared.initialize()
7
DriveKitUI.shared.initialize()
8
DriveKitVehicleUI.shared.initialize()
9
...
10
}
Copied!

Display vehicle list in navigation controller

To display the vehicle list to the driver, just call the following method:
1
self.navigationController?.pushViewController(DriveKitVehicleUI.shared.getVehicleListViewController(), animated: true)
Copied!

Display vehicle detail in navigation controller

To display the vehicle detail, just call the following method:
1
DriveKitVehicleUI.shared.getVehicleDetailViewController(vehicleId: viewModel.trip.vehicleId, completion: { [weak self] viewController in
2
DispatchQueue.main.async {
3
if let vehicleDetailViewController = viewController {
4
self?.navigationController?.pushViewController(vehicleDetailViewController, animated: true)
5
}
6
}
7
})
Copied!

Display vehicle picker in navigation controller

To display vehicle selection screens, just call the following method:
1
DKVehiclePickerNavigationController(parentView: <UIViewController>, detectionMode: <DKDetectionMode>, vehicle: nil, completion: {
2
// End of vehicle selection
3
})
Copied!