Phonegap plugin for the Zendrive SDK.
platforms: android,ios
$ cordova plugin add com.zendrive.phonegap.sdk


This is the official plugin for zendrive in Apache Cordova/PhoneGap!

Zendrive is commited to improving driving and transportation for everyone through better data and analytics.
You can integrate zendrive-sdk-phonegap-plugin in your application to get Zendrive's driver centric analytics and insights for your fleet.

Zendrive plugin performs three key functions.

  • Automatically collects data from various sensors on mobile phone while minimizing the battery impact.
  • Provides end points to application to manually start/end drives.
  • Uploads the data back to Zendrive servers for analysis.

How to integrate

Integrate zendrive phonegap plugin by running the following cordova command

cordova plugin add https://github.com/zendrive/zendrive-sdk-phonegap-plugin

Alternatively if you are using plugman in your application then use the following

For Android
plugman install --platform android --project ./platforms/android --plugin https://github.com/zendrive/zendrive-sdk-phonegap-plugin.git
For iOS
plugman install --platform ios --project ./platforms/ios --plugin https://github.com/zendrive/zendrive-sdk-phonegap-plugin.git

Alternatively if you are using phonegap build then add the following in your config.xml ( plugin only supported for android )

<gap:plugin name="com.zendrive.phonegap.sdk" version="1.2.1" />

Enable Zendrive in the app

Initialize the SDK

Typically this is done after the driver logs into the application and you know the identity of the driver. After this call, Zendrive SDK will start automatic trip detection and collect driver data. You can also record trips manually from your application.

cordova.exec(callback, function(err){alert(err)},"Zendrive","setup", [ ZENDRIVE_APPLICATION_KEY, <DRIVER_ID>]);

  • If you don't have the ZENDRIVE_APPLICATION_KEY, sign up on the Zendrive Developer Portal and get the key.
  • The is an ID for the driver currently using the application. Each driver using the application needs a unique ID

Manual Trip Tagging

The Zendrive SDK works in the background and automatically detects trips and tracks driving behaviour. However, some applications already have knowledge of point-to-point trips made by the driver using the application. For example - a taxi metering app. If your application has this knowledge, it can indicate that to the Zendrive SDK explicitly.

cordova.exec(callback, function(err){alert(err)},"Zendrive","startDrive", [<TRACKING_ID>]);

The <TRACKING_ID> can be used to find Zendrive trips with this ID in the Zendrive Analytics API. See the SDK Reference for more details about these calls.

Driving Sessions

Some applications want to track multiple point-to-point trips together as a single entity. For example, a car rental app may want to track all trips made by a user between a rental car pickup and dropoff as a single entity. This can be done using sessions in the Zendrive SDK. Sessions can be used in the Zendrive SDK by making the following calls.

cordova.exec(callback, function(err){alert(err)},"Zendrive","startSession", [<SESSION_ID>]);

All trips within a session are tagged with the <SESSION_ID>. The session id can then be used to lookup Zendrive trips belonging to this session using the Zendrive REST API.

Disable the SDK

To disable the SDK at any point in the application, you can invoke this method. The Zendrive SDK goes completely silent after this call and does not track any driving behaviour again.

cordova.exec(callback, function(err){alert(err)},"Zendrive","teardown", []);

The application needs to re-initalize the SDK to start tracking driving behaviour.