Skip to content

Development Guides

First, the DriveMotion client instance needs to be created.

The initialize method will only need to be called once.

DriveMotion Client Initialization

Import module, create a new instance of builder and set all needed data then initialize.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import DriveMotion, { DriveDetectionMode, DriveMotionBuilder } from "@telenav/react-native-data-collector-bridge";

const builderData = new DriveMotionBuilder()
  .setApiKey('apiKey')
  .setApiSecret('apiSecret')
  .setCloudEndPoint('https://endpoint')
  .setDeviceId('deviceId')
  .setUserId('userId')
  .setRunInBackgroundMode(true)
  .setApplicationInfo({
    name: 'name',
    version: 'version',
  })
  .setDriveDetectionMode(DriveDetectionMode.AUTO)
  .build()

DriveMotion.initialize(builderData);

Note

  1. setDeviceId('deviceId') is optional, device id will be automatically generated in event if it is not set.
  2. setRunInBackgroundMode(true) will enable data collection while application UI is in background.
  3. setDriveDetectionMode(true) is optional, auto trip detection is enabled by default. This setting will control auto trip detection. Set the value to false enable manual start/stop drive operations.

API Reference

Methods

Initialize SDK with proper data:

1
DriveMotion.initialize(builderData);

Shutdown SDK:

1
DriveMotion.shutdown();

You can start/stop drive in manual mode:

1
2
DriveMotion.stopDrive();
DriveMotion.startDrive();

Get stored trips:

1
DriveMotion.getTrips(startDate, endDate, limit, offset);

Get trip details:

1
DriveMotion.getTripDetails(tripId);

Get current live trip details:

1
DriveMotion.getLiveTripDetails();

Get aggregated trips score:

1
DriveMotion.getAggregatedScore(startDate, endDate, intervalType);

Events

Subscribe to event emitter:

1
DriveMotion.eventEmitter.addListener(...)

Following events are supported:

1
2
3
4
5
6
7
const DriveMotionBroadcast: {
    DriveStartEvent: "DriveStartEvent";
    DriveEndEvent: "DriveEndEvent";
    DriveEvent: "DriveEvent";
    DriveScoreEvent: "DriveScoreEvent";
    DriveAnalyzedEvent: "DriveAnalyzedEvent";
};