VehicleProvider
public protocol VehicleProvider : AnyObject
Responsible for control, access and notification of the vehicle state.
Important
This is a Public Preview API. It may be changed or removed at any time.-
Setting a different vehicle notifies observers of the latest vehicle state. To update only specific properties of the current vehicle, see
TomTomSDKVehicle/VehicleProvider/updateVehicleProperties(_:)
. Set vehicle on the main queue.Declaration
Swift
var vehicle: any Vehicle { get set }
-
Updates the specific properties of the current vehicle.
Throws
VehicleError.invalidVehicleProperty
, if the vehicleproperties
are not valid for the current vehicle type.Updating vehicle properties notifies observers of the latest vehicle state. To set a new vehicle, use
TomTomSDKVehicle/VehicleProvider/vehicle
. All vehicle updates must be done on the main queue.Declaration
Swift
func updateVehicleProperties(_ properties: [VehicleProperty]) throws
Parameters
properties
The vehicle properties to update.
-
Adds a
TomTomSDKVehicle/VehicleUpdateObserver
toVehicleProvider
. The call is expected on the main queue. The system keeps a weak reference to the observer.Declaration
Swift
func addVehicleUpdateObserver(_ observer: VehicleUpdateObserver)
Parameters
observer
A class that can handle vehicle update events.
-
Removes the
TomTomSDKVehicle/VehicleUpdateObserver
fromVehicleProvider
. There is no need to remove the observer. If the observer is not removed, the system will clean up when the next event is posted. The call is expected on the main queue. Do not call this method from the deinitializer of the observer, unless you are certain that the observer will be destroyed on the main queue.Declaration
Swift
func removeVehicleUpdateObserver(_ observer: VehicleUpdateObserver)
Parameters
observer
A class that can handle vehicle update events.