Skip to main content

Install SDK for Cordova

Add Hypertrack Plugin to project

Cordova HyperTrack plugin is available for Android platform. To use it add it to your project:

$ npx cordova add cordova-plugin-hypertrack-v3
note

We constantly work on making our SDKs better, so make sure you have the latest version. You can get it in changelog here.

Set you publishable Key

Inside your application logic initialize HyperTrack Plugin with your publishable Key

hypertrack.initialize( 'MY-PUBLISHABLE-KEY', onSuccess, onError );

Initializer follows standart practice and accepts success and error callbacks. Success callback receives SDK instance handle that you need to save for further usage:

var hypertrackSdk;

function onSuccess(sdkInstance) {
console.log("HyperTrack succesfully initialized");
hypertrackSdk = sdkInstance;

}

Set up silent push notifications

The SDK has a bi-directional communication model with the server. This enables the SDK to run on a variable frequency model, which balances the fine trade-off between low latency tracking and battery efficiency, and improves robustness. This also enables HyperTrack Trips to start and stop tracking automatically when trip starts and ends. For this purpose, the iOS SDK uses APNs silent remote notifications and Android SDK uses FCM silent notifications.

Identify your device

We use internal unique identifiers to manage the devices, so in order to be able to distinguish between users you need to get this device id and pass it to your backend to establish user to deviceId mapping.

  hypertrackSdk.getDeviceId(
function(deviceId) {
console.log("HyperTrack device id is " + deviceId);
user.hyperTrackDeviceId = deviceId;
},
function(err) {console.log("HyperTrack: can't get device id due to err " + err);}
);

Give your device a name

You can set device name that will show up in your Dashboard and attach metadata. You might wish to look at this guide on how to use it.

hypertrackSdk.setDeviceName(user.fineUserName);
hypertrackSdk.setDeviceMetadata({ region: 'Bay Area', manager: 'William Hill' });

Request permissions

HyperTrack needs access to device's geolocation and motion sensors to detect its position. Although you can use third party libraries to present the dialog, sdk has convenience method for it.

hypertrackSdk.requestPermissionsIfNecessary();

Resolve blockers

HyperTrack SDK requires some preconditions to track reliably. Since those vary across platforms and versions, we recommend using Blockers API to get the list of things to be resolved. Use getBlockers SDK method to get them. If the result is empty - you can navigate users to the screen, that has tracking feature, otherwise show an appropriate prompt, using blocker properties and nudge customer to resolve the issue, by invoking blocker.resolve(). The following action is context dependent, e.g. in the case of disabled geolocation an appropriate settings page will be opened with location switch been highlighted. Possible usage might look similar to shown below.

hypertrack.getBlockers(
function(blockers) {
let dialogConfig = [];
blockers.forEach(blocker =>
let menuItem = {
title: blocker.userActionTitle,
buttonName: blocker.userActionCTA,
onClick: function() {blocker.resolve(success, error);},
actionExplanation: blocker.userActionExplanation
};
dialogConfig.push(menuItem);
);
if (dialogConfig.length) showErrorDialog(dialogConfig);
},
function(error) {
console.log("Can't get blockers due to the error: " + error);
}
);

Prepare for App Store and Play Market submission

Read the Prepare for App Store submission section of iOS SDK guide and Get approved for the background location access section of Android SDK guide.

You are all set

Once your app is running, go to the dashboard where you can see a list of all your devices and their live location with ongoing activity on the map.

SDK integration examples

To learn more about SDK integration examples, you may visit these resources:

Frequently Asked Questions

Support

Join our Slack community for instant responses. You can also email us at help@hypertrack.com.