• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Simple Asset Tracking Example

This example guides you through the following steps:

  • Initialization with Customized Configurations: Learn how to set up the SDK with customized configuration values, tailoring it to your specific requirements and preferences.

  • Updating Configuration Settings at Runtime: Discover how to dynamically modify configuration settings such as LocationConfig, NotificationConfig, and DataTrackingConfig during the execution of your application. This flexibility empowers you to adapt the SDK to changing conditions and user needs in real time.

For all code examples, refer to iOS Tracking Android Code Examples

UpdateConfigurationViewController view source

1class UpdateConfigurationViewController: UIViewController {
2 @IBOutlet weak var updateLocationConfigBtn: UIButton!
3 @IBOutlet weak var updateNotificationConfigBtn: UIButton!
4 @IBOutlet weak var updateDataTrackingConfigBtn: UIButton!
5 @IBOutlet weak var configurationInfo: UILabel!
7 override func viewDidLoad() {
8 super.viewDidLoad()
9 let assetTracking = AssetTracking.shared
11 let locationConfig = LocationConfig(trackingMode: .ACTIVE)
12 locationConfig.distanceFilter = 5
13 assetTracking.setLocationConfig(config: locationConfig)
15 let notificationConfig = NotificationConfig()
16 notificationConfig.showLowBatteryNotification = true
17 assetTracking.setNotificationConfig(config: notificationConfig)

Upon executing the code example provided above, your app's appearance will resemble the following snippet:


Code Highlights

The above code snippet is a class inherited from the UIViewController class, which is the base class for all view controllers in iOS.

  • The class has three outlet properties: updateLocationConfigBtn, updateNotificationConfigBtn, and updateDataTrackingConfigBtn. These properties are linked to the corresponding UI elements in the view controller's storyboard.

  • The class has three methods to update the location configuration, notification configuration, and data tracking configuration, respectively. These methods call the AssetTracking.shared.updateLocationConfig(), AssetTracking.shared.updateNotificationConfig(), and AssetTracking.shared.updateDataTrackingConfig() methods, respectively.

  • The class has a createAsset() method to create a new asset.

  • The class has a bindAssetAndStartTracking() method to bind the asset to the current view controller and start tracking it.

Here is a more detailed explanation of some of the key concepts in the code:

  • AssetTracking: This is the class that is responsible for tracking assets.

  • LocationConfig: This class represents the configuration for location tracking.

  • NotificationConfig: This class represents the configuration for notification settings.

  • DataTrackingConfig: This class represents the configuration for data tracking settings.

Have Questions ?