Skip to content

Development Guides

To use data collector service and its features, the DataCollector client instance needs to be created.

The initialize method will only need to be called once.

DataCollector 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
import DataCollector, { DataCollectorBuilder } from "@telenav/react-native-data-collector-bridge";

const builderData = new DataCollectorBuilder()
  .setApiKey("#API_KEY_PROVIDED_BY_TELENAV#")
  .setApiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
  .setCloudEndPoint("#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
  .setApplicationInfo({ name: '#YOUR_APP_NAME#', version: '#YOUR_APP_VERSION#'})
  .setUserId("#USER_ID#")
  .setDeviceId("#DEVICE_ID#")
  .setBackgroundCollectingEnabled(true)
  .setTripDetectionEnabled(true)
  .build();

DataCollector.initialize(builderData);

Note

  1. setDeviceId("#DEVICE_ID#") is optional, device id will be automatically generated in event if it is not set.
  2. setBackgroundCollectingEnabled(true) will enable data collection, and set the value to false will disable data collection.
  3. setTripDetectionEnabled(true) is optional, auto trip detection is enabled by default. This setting will control auto trip detection, and set the value to false will disable auto trip detection.

API Reference

Methods

Initialize data collector with proper data:

1
DataCollector.initialize(builderData);

You can pause and resume when it needed:

1
2
DataCollector.stop();
DataCollector.start();

To turn off data collector by using shutdown method:

1
DataCollector.shutdown();