Configuration

这篇文档目前尚未提供译文,将以原文展示。

Asset tracking SDK provides a variety of configuration methods, users can customize data reporting, location data collection, notification, and Android services during Asset tracking SDK initialization.

An example of the configuration module usage during SDK initialization is presented as follows:

1AssetTracking {
2   setDefaultConfig(
3       DefaultConfig( )
4   )
5   setLocationConfig(
6       LocationConfig(
7           trackingMode = TrackingMode.ACTIVE
8
9       )
10   )
11   setNotificationConfig(
12       NotificationConfig(
13           title = "NextBillion.ai",
14           content = "Asset tracking is now enabled and your device's location will be tracked",
15       )
16   )
17   setDataTrackingConfig(
18       DataTrackingConfig(
19           baseUrl = baseUrl,
20           dataUploadingBatchSize = 30,
21           dataUploadingBatchWindow = 20,
22           dataStorageSize = 5000,
23           shouldClearLocalDataWhenCollision = true
24       )
25   )
26   initialize("YOUR_ACCESS_KEY")
27}

The classes corresponding to the configuration are:

  1. DataTrackingConfig : Data caching and reporting configuration

  2. DefaultConfig: Foreground service configuration

  3. LocationConfig: Location update configuration

  4. NotificationConfig: Notification configuration

The following methods are related to configuration in this SDK:

1/**
2* Set the support configuration for the AssetTracking SDK
3* Invoke before 'startTracking()'
4*/
5assetTrackingSetDefaultConfig(config: DefaultConfig)
6
7/**
8* Get the support configuration for the AssetTracking SDK
9*/
10assetTrackingGetDefaultConfig()
11
12/**
13* Set the notification configuration for the AssetTracking SDK
14* Invoke before 'startTracking()'
15*/
16assetTrackingSetNotificationConfig(config: NotificationConfig)
17
18/**
19* Update the notification configuration for the AssetTracking SDK
20* Invoke after 'startTracking()'
21*/
22assetTrackingUpdateNotificationConfig(config: NotificationConfig)
23
24/**
25* Get the notification configuration for the AssetTracking SDK
26*/
27assetTrackingGetNotificationConfig()
28
29/**
30* Set the Location configuration for the AssetTracking SDK
31* Invoke before 'startTracking()'
32*/
33assetTrackingSetLocationConfig(config: LocationConfig)
34
35/**
36* Update the Location configuration for the AssetTracking SDK
37* Invoke after 'startTracking()'
38*/
39assetTrackingUpdateLocationConfig(config: LocationConfig)
40
41/**
42* Get the Location configuration for the AssetTracking SDK
43*/
44assetTrackingGetLocationConfig()
45
46/**
47* Set the DataTracking configuration for the AssetTracking SDK
48* Invoke before 'startTracking()'
49*/
50assetTrackingSetDataTrackingConfig(config: DataTrackingConfig)
51
52/**
53* Update the DataTracking configuration for the AssetTracking SDK
54* Invoke after 'startTracking()'
55*/
56assetTrackingUpdateDataTrackingConfig(config: DataTrackingConfig)
57
58/**
59* Get the DataTracking configuration for the AssetTracking SDK
60*/
61assetTrackingGetDataTrackingConfig()

DataTrackingConfig

DataTrackingConfig includes the following parameters that are configurable during SDK initialization:

1data class DataTrackingConfig{
2   var baseUrl: String
3   var dataStorageSize: Int
4   var dataUploadingBatchSize: Int
5   var dataUploadingBatchWindow: Int
6   var shouldClearLocalDataWhenCollision: Boolean
7}
  1. baseUrl will be used for API related services.

  2. 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)

  3. 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.

  4. shouldClearLocalDataWhenCollision is the flag to control whether to clear locally cached location data if assetId is taken by another device

    1. If enabled, all the unsent location data will be cleared once asset id is taken, may cause data loss

    2. If disabled, unsent location data will remain cached and continue to upload once user rebinds, but this may cause dirty data issues.

DefaultConfig

DefaultConfig is used to configure the running status of the foreground service, Here is a summary of the properties:

  1. debug: A flag indicating the debug mode, determining whether to enable debug mode.

  2. enhanceService: A flag used to determine whether to enable the enhanced service. If set to true, it raises the priority of the service to ensure that the service stays alive until AssetTracking.stopTracking is called. However, it also increases power consumption.

  3. workerEnabled: A flag determining whether WorkManager can be used.

  4. crashRestartEnabled: A flag determining whether the application can be restarted when it crashes.

  5. workOnMainThread: A flag determining whether the service callback works on the main thread.

  6. restartIntent: The Intent used when the application is restarted.

LocationConfig

LocationConfig includes the following parameters that are configurable during SDK initialization:

1data class LocationConfig(
2   val trackingMode: TrackingMode = TrackingMode.ACTIVE,
3   var interval: Long = 1000,
4   var smallestDisplacement: Float = 10.0f,
5   var maxWaitTime: Long = 1000,
6   var fastestInterval: Long = 1000,
7   var enableStationaryCheck: Boolean = false,
8)
  1. trackingMode is the mode used in location data tracking, as is explained in the previous section, different tracking modes will have different location accuracy, time interval, and distance interval, thus resulting in different battery consumption. For details, please refer to Tracking Mode.

  2. Interval is the desired interval between location updates in milliseconds

  3. smallestDisplacement is the distance between location updates in meters

  4. maxWaitTime is the maximum wait time in milliseconds for location updates in milliseconds

  5. fastestInterval indicates for the fastest interval in milliseconds for location updates in milliseconds

  6. enableStationaryCheck indicates whether to enable stationary check for SDK if enabled, when SDK detects the asset is in stationary, will switch to energy saving tracking mode, and revert to the original mode when an asset moves again.

NotificationConfig

After launching asset tracking, we display a notification in the notification bar indicating that asset tracking is running. Users can customize the notification style using the NotificationConfig. They can set the title, text, icon, and other properties. When asset tracking is stopped, we also send a system notification to inform the user that asset tracking has stopped. The content of this notification can be customized using contentAssetDisable.

Here is a summary of the properties:

  1. serviceId: The ID of the notification service.

  2. channelId: The ID name of the notification channel.

  3. channelName: The name of the notification channel.

  4. title: The title of the notification view.

  5. content: The content of the notification view.

  6. smallIcon: The resource ID of the small icon image for the notification view.

  7. largeIcon: The resource ID of the large notification icon.

  8. largeIconBitmap: The bitmap for the big icon image of the notification view.

  9. remoteViews: Custom layout for the remote view.

  10. bigRemoteViews: Custom large layout for the remote view.

  11. pendingIntent: The PendingIntent instance for handling notification click.

  12. notification: The Notification instance set by the user.

  13. notificationChannel: The NotificationChannel set by the user.

  14. showLowBatteryNotification: A flag to determine whether to display the low battery notification. By default, the value is true

  15. lowBatteryNotification: Customization options for the low battery notification.

  16. contentAssetDisable: The content of the notification view when asset tracking is disabled.

  17. assetIdTakenContent: The content of the notification view when the asset id is taken by another device.

By default, when the battery level goes below a certain threshold, a notification is triggered to alert the user. Users can customize the title, text, icon, and other properties of the low-battery notification using LowBatteryNotificationConfig. If the user doesn't want to receive low battery notifications, they can disable it by setting the showLowBatteryNotification property in NotificationConfig. Here is a summary of the properties in LowBatteryNotificationConfig.

  1. threshold: The low battery warning threshold. If the battery level falls below this value and NotificationConfig.showLowBatteryNotification is true, a notification will be posted. By default the value is 20.

  2. channelId: The ID name of the notification channel for low battery notification.

  3. channelName: The name of the notification channel for low battery notification.

  4. title: The title of the low battery notification view.

  5. content: The content of the low battery notification view. It includes a placeholder ${threshold} that gets replaced with the actual threshold value.

  6. smallIcon: The resource ID of the small icon image for the low battery notification view.

  7. pendingIntent: The PendingIntent instance for handling notification click.

Getting Started
Location manager
没找到你要找的内容?