AI-generated Key Takeaways
-
The
GMTDVehicleReporterclass is used to send vehicle information to the Fleet Engine backend, and should only be used from the main thread. -
Location tracking can be enabled or disabled using the
locationTrackingEnabledproperty, which dictates whether updates are sent at regular intervals or a one-off update to set the vehicle toGMTDVehicleStateOffline. -
The frequency of location reports to Fleet Engine is controlled by the
locationReportingIntervalproperty, with a default of 10 seconds and a supported range between 5 and 60 seconds. -
The
updateVehicleStatemethod allows updating the vehicle's state, with special handling required when location tracking is disabled; failures in this process are automatically retried when location tracking is enabled. -
Listeners can be added and removed to monitor vehicle updates using the
addListener:andremoveListener:methods, respectively.
GMTDVehicleReporter
@interface GMTDVehicleReporter
: NSObject <GMSNavigatorListener, GMSRoadSnappedLocationProviderListener>Object for sending information to the Fleet Engine backend.
Use this class only from the main thread.
-
Unavailable
This class has no public initializers; obtain this object from the
vehicleReporterproperty of theGMTDDeliveryDriverAPIorGMTDRidesharingDriverAPIobject.Declaration
Objective-C
- (null_unspecified instancetype)init; -
Indicates whether location tracking is enabled.
If set to YES, trip and vehicle updates are sent to the Fleet Engine backend at a regular interval based on the value set for
locationUpdateInterval.If set to NO, updates stop and a one-off vehicle update request is sent to the Fleet Engine backend to set the vehicle state to
GMTDVehicleStateOffline. SeeupdateVehicleStatefor special considerations on handling failures whenlocationTrackingEnabledis set to NO.Declaration
Swift
var locationTrackingEnabled: Bool { get set }Objective-C
@property (nonatomic) BOOL locationTrackingEnabled; -
Indicates the minimum interval at which location reports will be delivered to Fleet Engine.
NOTE: The default reporting interval is 10 seconds. The maximum supported value is 60 seconds and the minimum supported value is 5 seconds. If a value outside of this range is used, the requested value is clamped to that range.
Declaration
Swift
var locationReportingInterval: TimeInterval { get set }Objective-C
@property (nonatomic) NSTimeInterval locationReportingInterval; -
Updates the vehicle state. Used only for ridesharing.
If
locationTrackingEnabledis set to NO, setting the state toGMTDVehicleStateOnlinefails.Setting a different state will send a one-off request to the Fleet Engine backend.
This method updates a server-side state, the client app should monitor
-fleetEngine:didSucceedVehicleUpdate:and-fleetEngine:didFailVehicleUpdate:withError:to confirm success or failure. Failures are retried automatically iflocationTrackingEnabledis set to YES.Declaration
Swift
func update(_ vehicleState: GMTDVehicleState)Objective-C
- (void)updateVehicleState:(GMTDVehicleState)vehicleState;Parameters
vehicleStateThe desired vehicle state.
-
Adds a listener. The listener is held with a weak reference.
Declaration
Swift
func add(_ listener: any GMTDVehicleReporterListener)Objective-C
- (void)addListener:(nonnull id<GMTDVehicleReporterListener>)listener;Parameters
listenerAn object conforming to the
GMTDVehicleReporterListenerprotocol. -
Removes a listener.
Declaration
Swift
func remove(_ listener: any GMTDVehicleReporterListener)Objective-C
- (void)removeListener:(nonnull id<GMTDVehicleReporterListener>)listener;Parameters
listenerAn object conforming to the
GMTDVehicleReporterListenerprotocol.