Basic integration

Once the module has been installed and you have configured your publishable token, you can use the methods of the SDK.

In case you are not using Cordova, you can refer to the Android version, or the iOS version.

Step 1: Define a user

To be able to identify the device, the SDK needs a user id. You can create a new user user on the SDK, and specify a string identifier. This is a network call that requires the device to be online.

[info] User already created?

You can set an existing user id, in case you have created an user id via the backend API using the hypertrack.setUserId("YOUR_USER_ID", (e) => {}, (e) => {}) method in the SDK.

var hypertrack = cordova.plugins.HyperTrack;
hypertrack.getOrCreateUser("USER_NAME", "USER_PHONE_NUMBER", "LOOKUP_ID", 
    (e) => {
        console.log('getOrCreateUser success', e)

        // Handle getOrCreateUser API success here
        ...
    },
    (e) => {
        console.log('getOrCreateUser error', e)

        // Handle getOrCreateUser API success here
        ...    
});

Step 2: Start tracking

Once the user id has been defined, the SDK can start tracking. Use the startTracking method to enable the SDK for tracking. You can use the callback methods to confirm tracking is working.

var hypertrack = cordova.plugins.HyperTrack;
hypertrack.startTracking(
    (e) => {
        console.log('startTracking success.', e)

        // Handle startTracking API success here
        ...
    },
    (e) => {
        console.log('startTracking error', e)

        // Handle startTracking API error here
        ...
});

Step 3: View dashboard

Install your app with the HyperTrack SDK on a device and begin tracking on the Dashboard. You would see the user’s current state on the HyperTrack dashboard. If you click on the user, you should be able to view the user's trips and stops.

Step 4: Stop tracking

When you want to disable the SDK and stop tracking, call the stopTracking method. You can confirm the SDK is inactive by checking the callback methods.

var hypertrack = cordova.plugins.HyperTrack;
hypertrack.stopTracking(
    (e) => {
        console.log('stopTracking success', e)
        // Handle stopTracking API success here
        ...
    }, 
    (e) => {
        console.log('stopTracking error', e)
        // Handle stopTracking API error here
        ...
});

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""