Configuration
Asset tracking SDK provides a variety of configuration methods, users can customize data reporting, location data collection, and notification during Asset tracking SDK initialization.
An example of the configuration module usage during SDK initialization is presented as follows:
The classes corresponding to the configuration are:
-
DataTrackingConfig: Data caching and reporting configuration
-
LocationConfig: Location update configuration
-
NotificationConfig: Notification configuration
The following methods are related to the configuration in this SDK:
DataTrackingConfig
DataTrackingConfig includes the following parameters that are configurable during SDK initialization:
-
baseUrl will be used for API related services.
-
dataStorageSize is the maximum available local storage for the Asset Tracking SDK data caching (location record number in Int, default is 5000, each record contains dataUploadingBatchSize location data, and takes one API call to upload)
-
dataUploadingBatchSize (default 30) and dataUploadingBatchWindow(in seconds, default 20 seconds) is for tracked location uploading. The SDK will upload data for every batch window, with no more than the batch size location data. So it is important to configure a proper value for this, otherwise, data will be uploaded with a huge delay.
-
shouldClearLocalDataWhenCollision is the flag to control whether to clear local cached location data if assetId is taken by another device
-
If enabled, all the unsent location data will be cleared once asset id is taken, which may cause data loss
-
If disabled, unsent location data will remain cached and continue to upload once user rebinds, but this may cause dirty data issues.
-
LocationConfig
The LocationConfig
is used to configure the location tracking settings. It allows customization of various parameters that influence the behavior of location updates.
-
trackingMode: Enumerates the tracking mode, which influences the frequency and accuracy of location updates. Options include TrackingMode.ACTIVE, TrackingMode.BALANCED and TrackingMode.PASSIVE. For details, please refer to Tracking Mode.
-
distanceFilter: Specifies the minimum distance (in meters) that a device must move before a new location update is generated. Movement less than this distance will not trigger updates unless accuracy improves. The default is 5 meters.
-
desiredAccuracy: Specifies the desired accuracy for location updates. The location service will attempt to achieve this accuracy, but it's not guaranteed. Options include kCLLocationAccuracyBest for the best accuracy and kCLLocationAccuracyBestForNavigation for navigation. Default values depend on the platform.
-
enableStationaryCheck: Whether to enable stationary check when doing data tracking, enable this will increase battery consumption and the speed capturing accuracy
Tracking Mode
Location Tracking Mode determines how frequently and accurately the location updates are obtained during tracking. There are three different tracking modes available:
Tracking Mode | Accuracy | Distance interval | Description |
---|---|---|---|
ACTIVE | High (the most accurate location) | 5m | This mode is suitable for applications that require precise and real-time location updates. It provides high accuracy at the cost of increased battery usage. |
BALANCED | Medium (optimized for battery usage) | 20m | This mode strikes a balance between accuracy and battery usage. It provides moderately accurate location updates at a lower frequency, resulting in better battery performance compared to the active mode. |
PASSIVE | Low (coarse ~ 10 km accuracy location) | 100m | This mode is designed for minimal battery consumption. It provides low-accuracy location updates at longer intervals, making it suitable for scenarios where periodic location updates are sufficient and power efficiency is critical. |
When selecting a tracking mode, you should consider the specific needs of your application.
- TRACKING_MODE_ACTIVE (Default): When you require highly accurate and real-time location updates.
- TRACKING_MODE_BALANCED: When a balance between accuracy and battery usage is desired.
- TRACKING_MODE_PASSIVE: When power efficiency is a priority and lower accuracy is acceptable.
In the meantime, you are also able to update the related configuration value after the initialization of LocationConfig
, and do the data tracking with the updated CUSTOM MODE.
Initializing with Default Settings
Create a LocationConfig instance with default settings. The trackingMode
, desiredAccuracy
, and distanceFilter
properties are initialized with their default values. This is suitable if you want to use the default settings for location tracking.
Initializing with Specific Tracking Mode
Create a LocationConfig
instance, and custom the trackingMode
property. The desiredAccuracy and distanceFilter properties are then automatically adjusted based on the specified tracking mode. This is useful if you want to prioritize a specific tracking mode and let the other properties adapt accordingly.
Customizing After Initialization
Create a LocationConfig instance
, and custom the trackingMode
property, the desireAccuracy and distanceFilter properties are then customized.
NotificationConfig
The NotificationConfig
is used to manage the notification-related configurations. It allows customization of various parameters that influence the behavior of different types of notifications.
-
assetEnableNotificationConfig: The configuration for starting asset tracking notifications.
-
assetDisableNotificationConfig: The configuration for stopping asset tracking notifications.
-
lowBatteryNotificationConfig: The configuration for low-battery notifications.
-
showAssetEnableNotification: Determines whether to display notifications for start asset tracking.
-
showAssetDisableNotification: Determines whether to display notifications for stop asset tracking.
-
showLowBatteryNotification: Determines whether to display notifications for low battery conditions.
Initializing with Default Settings
Use the default notification settings
Customizing Notification Configuration
Create a NotificationConfig instance with default settings. Customize the assetEnableNotificationConfig by creating an AssetEnableNotificationConfig instance with specific parameters like identifier
, title
, and content
.