Inside the Geotab Drive app, we provide the same API and state properties for your initialize method that we do for our normal Add-Ins. In addition to this, we provide you with properties and methods to allow access to mobile device sensors/actuators.

Geotab Drive page lifecycle methods

The onStartup and onShutdown properties respectively enable the startup and shutdown lifecycle methods.

Startup

When the dashboard page is visible, the startup method is only called once. If the user navigates away from the page then navigates back, the startup method is not called again. If the Add-In requires re-initialization, the user must either log out and log in again, or refresh the application.

Shutdown

Shutdown Add-Ins are executed when the final driver logs out of the Drive App. If there are co-drivers, and one of the co-drivers logs out (while other drivers remain logged in to the Drive App), the shutdown Add-In is not executed.

Additionally, the Add-In is expected to return a promise since shutdown Add-Ins have a 15-second time limit to perform their function before the Add-Ins time out and the logout process is completed. The time limit prevents the application from freezing in the middle of the logout process as a result of faulty Add-Ins.

Methods

api.mobile.camera.takePicture (...)

If api.mobile.exists(), will open up a modal with the following options New Picture and Upload.

api.mobile.dutyStatusLog.add (...)

Adds a new DutyStatusLog. Note: The log will not be immediately added with this method, it will be synced during the next drive sync cycle.

api.mobile.dutyStatusLog.get (...)

Gets all of the DutyStatusLogs for the current user

api.mobile.dutyStatusLog.getCurrentDrivingLog (...)

Gets the current DutyStatusLog of the driver.

api.mobile.exists (...)

Returns true if Geotab Drive is running within a native application, and false if just as a HTML5 web application

api.mobile.getVersion (...)

If api.mobile.exists(), gets the Geotab Drive version from the native application

api.mobile.listenTo (...)

Event listener that executes the specified callback function whenever a change on the state is detected

api.mobile.navigate (...)

Navigates to default pages on Geotab Drive.

api.mobile.notification.cancel (...)

api.mobile.notification.hasPermission (...)

Asynchronously checks the notification permission for the Drive App and returns a promise.

api.mobile.notification.notify (...)

Sends a native notification to the user with the provided title and message. If the application does not yet have notification permission, we will requestNotificationPermission() thennotify() if the user granted permission; otherwise, the promise is rejected.

api.mobile.notification.requestPermission (...)

Checks the notification permission for the Drive App and returns a promise.

api.mobile.notification.update (...)

Allows you to update the content of active notifications. To update active notifications that have not yet been acknowledged, the original notification id -- created at the time the notification is sent -- must be provided.

api.mobile.shipment.add (...)

Adds a new ShipmentLog

api.mobile.shipment.get (...)

Gets the ShipmentLogs for the device.

api.mobile.shipment.remove (...)

Removes the specified ShipmentLog by setting the activeTo datetime string to the current date.

api.mobile.speak (...)

If api.mobile.exists(), uses the text to speech functionality on the mobile device

api.mobile.textMessage.add (...)

Adds a new TextMessage

api.mobile.textMessage.get (...)

Returns any TextMessage received in the current session.

api.mobile.textMessage.set (...)

Allows to update the properties for an existing TextMessage

api.mobile.trailer.get (...)

Retrieves trailer information

api.mobile.trailerAttachment.get (...)

Retrieves TrailerAttachment data

api.mobile.user.get (...)

Retrieves driver information

api.mobile.user.getAvailability (...)

Gets driver availability

api.mobile.user.getHosRuleSet (...)

Gets the HosRuleSet for the current driver

api.mobile.user.getViolations (...)

Gets driver violations

api.mobile.vehicle.get (...)

Retrieves current vehicle information
Objects

api.mobile.geolocation

A navigator object that is similar to HTML5 navigator.geolocation

state