DriveViewController
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
public override init(modules: Set<Module> = [], options: MobileSdkOptions = .default)
Parameters
modules
User implemented third party modules
options
Optional behaviors for the view ocntrollerr
-
Indicates whether the device is in charging state.
Declaration
Swift
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
public func cancelLogin()
-
Get all driver users signed in.
Declaration
Swift
public func getAllUsers(_ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
callback
Result is given as a JSON string representing an array of Users
-
Get the HOS Rule Set.
Declaration
Swift
public func getHosRuleSet(userName: String, _ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
callback
Result is given as a JSON string representing a HosRuleset
-
Get the User Availability.
Declaration
Swift
public func getUserAvailability(userName: String, _ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
callback
Result is given as a JSON string representing a DutyStatusAvailability
-
Get the User Violations.
Declaration
Swift
public func getUserViolations(userName: String, _ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
callback
Result is given as a JSON string representing a DutyStatusViolation
-
Set a driver in driver seat.
Declaration
Swift
public func setDriverSeat(driverId: String, _ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
driverId
String
callback
Result is given as a JSON string representing a User
-
Get the
Go Device
of Drive’sstate
.Declaration
Swift
public func getStateDevice(_ callback: @escaping (_ result: Result<String, Error>) -> Void)
Parameters
callback
Result 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
public func setSpeechEngine(speechEngine: SpeechEngine)
Parameters
speechEngine
SpeechEngine
-
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 Required
event will be triggered. SeesetLoginRequiredCallback
for more detail.Declaration
Swift
public func setSession(credentialResult: CredentialResult, isCoDriver: Bool = false)
Parameters
credentialResult
isCoDriver
Bool. 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
public func setCustomURLPath(path: String)
Parameters
path
Drive’s UI path to navigate to.
-
Set
DriverActionNecessary
callback to listen for such event sent from Web Drive.Declaration
Swift
public func setDriverActionNecessaryCallback(_ callback: @escaping DriverActionNecessaryCallbackType)
Parameters
callback
-
Clear
DriverActionNecessary
callback listener.Declaration
Swift
public func clearDriverActionNecessaryCallback()
-
Set
PageNavigation
callback listener.Declaration
Swift
public func setPageNavigationCallback(_ callback: @escaping PageNavigationCallbackType)
Parameters
callback
-
Clear
PageNavigation
callback listener.Declaration
Swift
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
DriveViewController
and present user with its Login screen.Declaration
Swift
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
LoginRequired
callback listener.Declaration
Swift
public func clearLoginRequiredCallback()
-
Set
LastServerAddressUpdated
callback 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
public func setLastServerAddressUpdatedCallback(_ callback: @escaping LastServerAddressUpdatedCallbackType)
Parameters
callback
-
Clear
LastServerAddressUpdated
callback listener.Declaration
Swift
public func clearLastServerAddressUpdatedCallback()