Vehicle management

DriveKit Vehicle component manages cars and trucks vehicles.

Methods presented in this part are available in the DriveKitVehicle class

Create a custom vehicle

It is possible to create a custom vehicle from your own data. Create your vehicle using the method:

func createCustomVehicle(
    characteristics: DKVehicleCharacteristics,
    name: String? = nil,
    id: String,
    completionHandler: @escaping (DKVehicleManagerStatus, DKVehicle?) -> Void
)

Each vehicle will have a unique identifier and this unique ID will be added into the trip synchronization response.

This method have the following parameters:

Check the DKVehicleManagerStatus value to ensure your vehicle is correctly created:

DKVehicle model is described in the References part.

Synchronize vehicle list

You can retrieve the user’s vehicle list from the DriveQuant servers by calling the following method:

func getVehiclesOrderByNameAsc(
    type: DKVehicleSynchronizationType = .defaultSync, 
    completionHandler: @escaping (DKVehicleSyncStatus, [DKVehicle]) -> Void
) 

This method have the following parameter:

DKVehicleSyncStatus and DKVehicle models are described in the References part.

Retrieve local vehicle list

You can retrieve the list of vehicles stored in the DriveKit local database by calling the previous method but with the type parameter to .cache.

Replace a vehicle

Instead of deleting and then creating a new vehicle, you can use only one method to replace an existing vehicle.

A previously paired beacon to that vehicle is automatically paired to the new vehicle.

Replace a car

func replaceWithCarVehicle(
        oldVehicleId: String,
        characteristics: DKCarVehicleCharacteristics,
        name: String? = nil,
        liteConfig: Bool = false,
        completionHandler: @escaping (DKVehicleReplaceStatus, DKVehicle?) -> Void
)

This method have the following parameters:

DKVehicleReplaceStatus and DKVehicle models are described in the References part.

Replace a truck

func replaceWithTruckVehicle(
        oldVehicleId: String,
        characteristics: DKTruckVehicleCharacteristics,
        name: String? = nil,
        completionHandler: @escaping (DKVehicleReplaceStatus, DKVehicle?) -> Void
)

This method have the following parameters:

DKVehicleReplaceStatus and DKVehicle models are described in the References part.

Delete a vehicle

When you delete a vehicle, a previously paired beacon or Bluetooth device to that vehicle is automatically unpaired and released from the vehicle. By this way, you can immediately pair the beacon or the Bluetooth device to another vehicle.

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

func deleteVehicle(
    vehicleId: String,
    completionHandler: @escaping (DKVehicleManagerStatus) -> Void
)

This method have the following parameter:

Check the DKVehicleManagerStatus value to ensure your vehicle is successfully deleted:

Rename a vehicle

To rename a vehicle, you have to call the following method:

func renameVehicle(
    name: String,
    vehicleId: String,
    completionHandler: @escaping (DKVehicleManagerStatus) -> Void
) 

This method have the following parameters:

Check the DKVehicleManagerStatus value to ensure your vehicle is successfully deleted:

Change the detection mode of a vehicle

When you have a vehicle, it is necessary to set its DetectionMode type. The following function is used to select the DetectionMode of a vehicle:

func updateDetectionMode(
    vehicleId: String,
    detectionMode: DKDetectionMode,
    forceGPSVehicleUpdate: Bool = false,
    completionHandler: @escaping (DKDetectionModeStatus) -> Void
)

This method have the following parameters:

DKDetectionModeStatus model is described in the References part.

Information: If a driver has more than one vehicle, only one can be configured in GPS mode. If you choose a GPS trigger mode for a vehicle while there is already another vehicle with this trigger mode, then you must specify the appropriate action with the forceGPSVehicleUpdate parameter to true. The other vehicle will have its detection mode updated to .disabled.

Last updated