Update Asset Configurations
This example shows:
- Initialize asset tracking: Initialize Asset tracking with necessary configurations such as API key, fake GPS configuration, and data tracking configuration.
- Create and Bind Asset: Creates a new asset profile and binds it to the asset tracking service. Ensures that the asset is ready for tracking.
- Update Data Tracking Configurations: Update data tracking configurations such as batch size, batch window, and storage size. This is achieved by creating a new DataTrackingConfig object and calling the setDataTrackingConfig() method of the asset tracking service.
- Update Location Configurations: Update location tracking configurations such as tracking mode and smallest displacement. This is done by creating a new LocationConfig object and calling the updateLocationConfig() method of the asset tracking service.
- Update Notification Configurations: Update notification configurations based on the platform (Android or iOS). For Android, it updates the Android notification configuration, for iOS, it updates the iOS notification configuration. These configurations include settings such as notification channel ID, notification channel name, and asset enable notification title.
For all code examples, refer to Asset Tracking Flutter Code Examples
update_tracking_configuration.dart view source
Here are the code highlights for each of the four functionalities:
-
Initialize Asset Tracking
assetTracking.initialize(apiKey: accessKey)
: Initializes asset tracking with the provided API key.assetTracking.setFakeGpsConfig(allow: true)
: Allows using fake GPS configurations.assetTracking.addDataListener(this)
: Adds a data listener to track data updates.assetTracking.setDataTrackingConfig(config: DataTrackingConfig(baseUrl: baseUrlStaging))
: Sets data tracking configurations such as the base URL.
-
Create and Bind Asset
AssetProfile profile = AssetProfile(...)
: Defines the profile of the asset to be created.AssetResult result = await assetTracking.createAsset(profile: profile)
: Creates a new asset with the specified profile.var assetResult = await assetTracking.bindAsset(customId: assetID)
: Binds the created asset to the tracking service.
-
Update Data Tracking Configurations
var dataTrackingConfig = DataTrackingConfig(...)
: Defines the data tracking configurations to be updated.await assetTracking.setDataTrackingConfig(config: dataTrackingConfig)
: Updates the data tracking configurations.var dataTrackingConfigInfo = await assetTracking.getDataTrackingConfig()
: Retrieves the updated data tracking configurations.
-
Update Location Configurations
var locationConfig = LocationConfig(...)
: Defines the location configurations to be updated.await assetTracking.updateLocationConfig(config: locationConfig)
: Updates the location tracking configurations.var locationConfigResult = await assetTracking.getLocationConfig()
: Retrieves the updated location tracking configurations.
-
Update Notification Configurations
- For Android:
var androidNotificationConfig = AndroidNotificationConfig(...)
: Defines the Android notification configurations.assetTracking.setAndroidNotificationConfig(config: androidNotificationConfig);
: Sets the Android notification configurations.var androidConfig = await assetTracking.getAndroidNotificationConfig();
: Retrieves the updated Android notification configurations.
- For iOS:
var iOSNotificationConfig = IOSNotificationConfig(...)
: Defines the iOS notification configurations.assetTracking.setIOSNotificationConfig(config: iOSNotificationConfig);
: Sets the iOS notification configurations.var iosConfig = await assetTracking.getIOSNotificationConfig();
: Retrieves the updated iOS notification configurations.
- For Android: