MTS SDK
MTS The Movement Tracking System (MTS) SDK is an Android SDK written in Java and Kotlin that enables real-time tracking of users and vehicles. It supports integration with both native Android and React Native applications, providing a reliable solution for monitoring movement and managing geofencing events.
The SDK includes a set of APIs that facilitate seamless communication with OS1 backend services, allowing developers to efficiently track movement, listen for event updates, and manage location-based triggers.
- Real-time Tracking – Capture and transmit live location updates.
- Event Listener Support – Subscribe to movement events and trip status updates.
- Geofencing – Define virtual boundaries and receive entry/exit notifications.
- Flexible Integration – Supports both native Android and React Native applications.
- Sync Location Trace both through REST API & MQTT (MQ Telemetry Transport) Protocol.
The MTS SDK is designed for applications that require accurate movement tracking, geofencing capabilities, and event-driven monitoring.
Currently, supports 21=<SDK<=29.
- Android application written in Java or Kotlin
- Minimum Android API level 21 (Lollipop)
- Internet access for API communication
- OS1 backend services configured and accessible
- Minimum SDK: 24
- Maximum SDK: 34
To install MTS SDK, run the following command:
- Import MTS SDK in your project:
2. Register the token expiry sync task in the root index file (index.ts):
The MTS SDK provides default configuration values that can be modified based on your specific use case. While modifying these values is optional, it allows you to fine-tune parameters such as location update frequency, accuracy, and data transmission behavior to better align with your application's needs.
Below is the default configuration provided by the SDK:
Parameter | Type | Default Value | Description |
---|---|---|---|
locationFrequency | number | 10000 | Time interval (in ms) for location updates. |
distanceAccuracyLimit | number | 250 | Accuracy threshold in meters. |
speedLimit | number | 28 | Maximum speed threshold in meters per second. |
mode | enum | HYBRID | MTS operation mode (HYBRID, GPS_ONLY, etc.). |
environment | enum | DEV | SDK environment (DEV or PROD). |
batchSize | number | 25 | Number of location events sent per batch. |
isMqttCleanSession | boolean | true | Determines whether MQTT uses a clean session. |
mqttKeepAliveInterval | number | 900 (15 min) | MQTT keep-alive interval in seconds. |
maxLocationAge | number | 15000 | Maximum allowed location age in milliseconds. |
maxTraceSession | number | 8640000 | Maximum session duration in milliseconds. |
isOdometerEnabled | boolean | true | Enables odometer tracking. |
retriesBeforeFallback | number | 1 | Number of retry attempts before fallback. |
httpFailureLimit | number | 5 | Number of failed HTTP requests before stopping. |
dataSendDelay | number | 30000 | Delay before sending data (milliseconds). |
alarmTime | number | 60000 | Alarm trigger time in milliseconds. |
missingSeqCheckDuration | number | 300000 (5 min) | Interval for checking missing sequences (milliseconds). |
odometerPushFrequency | number | 300000 (5 min) | Frequency of odometer updates (milliseconds). |
qosLevel | number | 1 | MQTT Quality of Service level (0 or 1). |
- If your application requires more frequent location updates, reduce locationFrequency.
- To improve accuracy, adjust distanceAccuracyLimit.
- If battery optimization is a concern, increase dataSendDelay to reduce network usage.
Ensure that mandatory permissions are granted before using MTS SDK:
See Error Codes for Possible error types.
PERMISSIONS_ERROR[2500] = "Mandatory Android Permissions not provided" MTS_INIT_ERROR[2501] ="MTS INIT Not called! MTS Device ID is Empty" PARAM_MISSING[2502] = "Mandatory Paramater is missing in request"
MTS SDK provides a real-time geofencing feature that:
- Tracks user ENTRY/EXIT events
- Syncs geofence events to the server in real-time
- Works in the background even if the app is killed
Geofencing process can only be started post calling "startMTS()" in your code. Whenever a geofence event is captured by MTS SDK. It will perform two actions:
- It will emit an event referring to a Geofence ENTRY/ EXIT to the integrating application.
- It will add an EVENT object to the existing MTS traces object.
Note: Ensure MTS service is running before calling startGeofence().
Ensure MTS service is running before calling startGeofence().
- Ensure that the MTS service is running before calling startGeofence(). Always invoke startMTS() first to start the MTS process before initiating geofencing.
- If startGeofence() is called again with the same geofenceRef value and abortExisting set to true, the existing geofence process will be terminated, and a new geofence process will be initiated with the same geofenceRef.
Possible return values:
- "ON-GOING"
- "ABORTED"
- "NO_STATUS_FOUND"
When a user enters/exits a geofence, the SDK:
- Emits an event to the integrating application:
- GEOFENCE_ENTRY: User enters geofence
- GEOFENCE_EXIT: User exits geofence
- Adds an event object to the MTS traces object
How to listen a geofence event on application end whenever an ENTRY/ EXIT event occurs: Events Constants: 1. GEOFENCE_ENTRY 2. GEOFENCE_EXIT
- START_GEOFENCE_ERROR_CODE[2507] = "Geofence start failed. Please try again".
- CHECK_GEOFENCE_STATUS_ERROR_CODE[2508] = "Geofence status check failed. Please try again".
- ABORT_GEOFENCE_ERROR_CODE[2509] = "Geofence abort failed. Please try again".
- FLUSH_GEOFENCE_ERROR_CODE[2510] = "Geofence data flush failed. Please try again".