DriveViewController
@MainActor
open class DriveViewController : SDKViewController
Drive’s View Controller and API interface. Everthing you need to launch a Drive. Only one instance should be created.
-
Initializer
Declaration
Swift
@MainActor public override init(modules: Set<Module> = [], options: MobileSdkOptions = .default)Parameters
modulesUser implemented third party modules
optionsOptional behaviors for the view ocntrollerr
-
Indicates whether the device is in charging state.
Declaration
Swift
@MainActor public var isCharging: Bool { get } -
Cancels a login request. When a user selects Add CoDriver in Drive, but does not to proceed to login, this function must be called. This function will navigate Drive to the most recent non-login page. If the login request is for a main driver , calling this function will dismiss the DriveViewController.
Declaration
Swift
@MainActor public func cancelLogin() -
Get all driver users signed in.
Declaration
Swift
@MainActor public func getAllUsers(_ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackResult is given as a JSON string representing an array of Users
-
Get the HOS Rule Set.
Declaration
Swift
@MainActor public func getHosRuleSet(userName: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackResult is given as a JSON string representing a HosRuleset
-
Get the User Availability.
Declaration
Swift
@MainActor public func getUserAvailability(userName: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackResult is given as a JSON string representing a DutyStatusAvailability
-
Get the User Violations.
Declaration
Swift
@MainActor public func getUserViolations(userName: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackResult is given as a JSON string representing a DutyStatusViolation
-
Set a driver in driver seat.
Declaration
Swift
@MainActor public func setDriverSeat(driverId: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
driverIdString
callbackResult is given as a JSON string representing a User
-
Get the
Go Deviceof Drive’sstate.Declaration
Swift
@MainActor public func getStateDevice(_ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackResult is given as a JSON string representation of a GoDevice
-
Set a custom speech Engine to replace the default one comes with the SDK.
Declaration
Swift
@MainActor public func setSpeechEngine(speechEngine: any SpeechEngine)Parameters
speechEngineSpeechEngine -
Set a new Geotab session for driver or co-driver. Setting a new session means adding a new driver to Drive. In case the given session is invalid,
Login Requiredevent will be triggered. SeesetLoginRequiredCallbackfor more detail.Declaration
Swift
@MainActor public func setSession(credentialResult: CredentialResult, isCoDriver: Bool = false)Parameters
credentialResultisCoDriverBool. Indicate if its’ for a co-driver login.
-
Set navigation path. “path” will be concatenated as follows: “https://
/drive/default.html?#${path}”. Once set, DriveViewController will navigate to the given UI path. This function can be used to implement iOS custom URL. For example by accepting “myscheme://dvir/main” as a launch URL, An app could navgate the app the requested path “dvir/main” on launch.
Declaration
Swift
@MainActor public func setCustomURLPath(path: String)Parameters
pathDrive’s UI path to navigate to.
-
Set
DriverActionNecessarycallback to listen for such event sent from Web Drive.Declaration
Swift
@MainActor public func setDriverActionNecessaryCallback(_ callback: @escaping DriverActionNecessaryCallbackType)Parameters
callback -
Clear
DriverActionNecessarycallback listener.Declaration
Swift
@MainActor public func clearDriverActionNecessaryCallback() -
Set
PageNavigationcallback listener.Declaration
Swift
@MainActor public func setPageNavigationCallback(_ callback: @escaping PageNavigationCallbackType)Parameters
callback -
Clear
PageNavigationcallback listener.Declaration
Swift
@MainActor public func clearPageNavigationCallback() -
Set a callback to listen for session changes. That includes: no session, invalid session, session expired, co-driver login is requested.
There are three defined values and variance of different error messages that could be passed in the callback.
- “”, empty string, indicates no login required or login is successful, or the login is in progress. At this state, implementor should presents the DriveViewController/Fragment.
- “LoginRequired”: indicates the login UI is going to show a login form(No valid user is available or the current activeSession is expired/invalid). At this state, implementor presents its own login screen.
- “AddCoDriver”: indicates that a co-driver login is requested. At this state, implementor presents its own co-driver login screen.
- Any error message, any other error messages. At this state, implementor presents its own login screen.
After receiving such session expired callback call. Integrator usually dismisses the presented
DriveViewControllerand present user with its Login screen.Declaration
Swift
@MainActor public func setLoginRequiredCallback(_ callback: @escaping LoginRequiredCallbackType)Parameters
callback- status:
"""LoginRequired","AddCoDriver". - errorMessage: Error happened during login process and error info is given in
errorMessage.
-
Clear
LoginRequiredcallback listener.Declaration
Swift
@MainActor public func clearLoginRequiredCallback() -
Set
LastServerAddressUpdatedcallback listener. Such event is sent by Drive to notify impelementor that a designated “server address” should be used for future launches. Implementor should save the new server address in persistent storage. In the future launches, app should set the DriveSdkConfig.serverAddress with the stored new address before creating an instance of DriveViewController. Note such address is not the same as the counterparty one in MyGeotabViewController.Declaration
Swift
@MainActor public func setLastServerAddressUpdatedCallback(_ callback: @escaping LastServerAddressUpdatedCallbackType)Parameters
callback -
Clear
LastServerAddressUpdatedcallback listener.Declaration
Swift
@MainActor public func clearLastServerAddressUpdatedCallback() -
Get the user’s duty dtatus log.
Declaration
Swift
@MainActor public func getDutyStatusLog(userName: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackString encoded list of log records
-
Get the user’s current driving logs.
Declaration
Swift
@MainActor public func getCurrentDrivingLog(userName: String, _ callback: @escaping (_ result: Result<String, any Error>) -> Void)Parameters
callbackString encoded list of log records