Data reporting


This module handles location data received from the device, processes it into a structured format known as LocationData, and stores it locally using the MMKV plugin.

LocationData Format

LocationData is a structured format that contains essential location information. It includes:

location: Represents the geographical coordinates in lat,lon format, where lat represents the latitude and lon represents the longitude of the location.

timeStamp: A UNIX Epoch timestamp in seconds indicating the time when the location was recorded.

accuracy: Reflects the accuracy of the location data in meters.

speed: Denotes the speed of the asset(device) movement in meters/second.

bearing: Represents the direction (bearing) in which the device is moving.

altitude: Indicates the altitude above sea level in meters.

1public class LocationData: NSObject, NSSecureCoding{
2   public let location: SimpleLocation
3   public let timeStamp: Int64
4   public let accuracy: Double
5   public let speed: Double
6   public let bearing: Double
7   public let altitude: Double
10public class SimpleLocation: NSObject, NSSecureCoding{
11   public let latitude: Double
12   public let longitude: Double

Data Uploading Process

The data uploading process happens discreetly in the background and is not visible to end-users. Here's how it works:

  1. Data uploading follows the user-defined parameters set in DataTrackingConfig, specifically dataUploadingBatchSize and dataUploadingBatchWindow.

  2. Data is uploaded in the order it was tracked, with earlier data taking priority.

  3. For each data upload operation, if there are more data in the local cache than the defined dataUploadingBatchSize, only the specified number of location data points are uploaded to the backend in one go.

  4. If there are less data in the local cache than the dataUploadingBatchSize, all available unsent data is uploaded in a single API call.

  5. Upon successful data upload, it is removed from the local cache to free up storage space. In case of upload failures, the next API call will prioritize uploading the previously failed data before proceeding with the remaining data.

  6. The behavior of clearing local unsent location data when another device takes the current asset ID is controlled by DataTrackingConfig.shouldClearLocalDataWhenCollision. If enabled, all local unsent location data will be cleared to ensure data integrity.

By understanding these simple principles, you can grasp the data reporting module's functionality and how it manages location data seamlessly within the SDK.

Asset Tracking Callback