Config class

Configuration API.

Instances of Config are consumed by BackgroundGeolocation.ready and BackgroundGeolocation.setConfig.

Example

Config params = new Config(
  desiredAccuracy: Config.DESIRED_ACCURACY_HIGH,
  distanceFilter: 10.0,
  stopOnTerminate: false,
  startOnBoot: true,
  url: 'http://my.server.com',
  params: {
    "user_id": 123
  },
  headers: {
    "my-auth-token":"secret-key"
  }
);

BackgroundGeolocation.ready(params).then((State state) {
  print('[ready] BackgroundGeolocation is configured and ready to use');

  BackgroundGeolocation.start();
});

// To modify config after #ready has been executed, use #setConfig
BackgroundGeolocation.setConfig(Config(
  headers: {
    "my-auth-token": "my-new-secret-key"
  }
)).then((State state) {
  BackgroundGeolocation.sync();
});
Implementers

Constructors

Config({int? desiredAccuracy, double? distanceFilter, double? stationaryRadius, int? locationTimeout, bool? disableElasticity, double? elasticityMultiplier, int? stopAfterElapsedMinutes, int? geofenceProximityRadius, int? maxMonitoredGeofences, bool? geofenceInitialTriggerEntry, double? desiredOdometerAccuracy, bool? useSignificantChangesOnly, String? locationAuthorizationRequest, bool? isMoving, int? stopTimeout, int? activityRecognitionInterval, int? minimumActivityRecognitionConfidence, bool? disableStopDetection, bool? stopOnStationary, String? url, int? persistMode, String? method, String? httpRootProperty, Map<String, dynamic>? params, Map<String, dynamic>? headers, Map<String, dynamic>? extras, bool? autoSync, bool? disableAutoSyncOnCellular, bool? disableProviderChangeRecord, int? autoSyncThreshold, bool? batchSync, int? maxBatchSize, String? locationTemplate, String? geofenceTemplate, int? maxDaysToPersist, int? maxRecordsToPersist, String? locationsOrderDirection, int? httpTimeout, Authorization? authorization, bool? stopOnTerminate, bool? startOnBoot, int? heartbeatInterval, List<String>? schedule, bool? scheduleUseAlarmManager, bool? debug, int? logLevel, int? logMaxDays, bool? reset, bool? pausesLocationUpdatesAutomatically, Map<String, dynamic>? locationAuthorizationAlert, bool? disableLocationAuthorizationAlert, bool? showsBackgroundLocationIndicator, int? activityType, int? stopDetectionDelay, bool? disableMotionActivityUpdates, bool? preventSuspend, int? locationUpdateInterval, int? fastestLocationUpdateInterval, int? deferTime, bool? allowIdenticalLocations, bool? enableTimestampMeta, int? speedJumpFilter, bool? geofenceModeHighAccuracy, String? triggerActivities, int? motionTriggerDelay, bool? enableHeadless, bool? foregroundService, bool? forceReloadOnLocationChange, bool? forceReloadOnMotionChange, bool? forceReloadOnGeofence, bool? forceReloadOnBoot, bool? forceReloadOnHeartbeat, bool? forceReloadOnSchedule, Notification? notification, int? notificationPriority, String? notificationTitle, String? notificationText, String? notificationColor, String? notificationSmallIcon, String? notificationLargeIcon, String? notificationChannelName, PermissionRationale? backgroundPermissionRationale, TransistorAuthorizationToken? transistorAuthorizationToken})

Properties

activityRecognitionInterval int?
Controls the sample-rate of the activity-recognition system.
getter/setter pair
activityType int?
[iOS only] Presumably, this affects iOS stop-detect algorithm. Apple is vague about what exactly this option does.
getter/setter pair
allowIdenticalLocations bool?
[Android only] Allow recording locations which are duplicates of the previous.
getter/setter pair
authorization Authorization?
Configure the SDK's HTTP service to authenticate with your server (eg: JWT)
getter/setter pair
autoSync bool?
Immediately upload each recorded location to your configured url.
getter/setter pair
autoSyncThreshold int?
The minimum number of persisted records the plugin must accumulate before triggering an autoSync action.
getter/setter pair
backgroundPermissionRationale PermissionRationale?
(Android 11+) Configure the dialog presented to the user when Always location permission is requested.
getter/setter pair
batchSync bool?
POST multiple locations to your url in a single HTTP request.
getter/setter pair
debug bool?
Configure the plugin to emit sound effects and local-notifications during development.
getter/setter pair
deferTime int?
[Android only] Sets the maximum wait time in milliseconds for location updates.
getter/setter pair
desiredAccuracy int?
Specify the desired-accuracy of the geolocation system.
getter/setter pair
desiredOdometerAccuracy double?
The maximum location accuracy allowed for a location to be used for Location.odometer calculations.
getter/setter pair
disableAutoSyncOnCellular bool?
Disable autoSync HTTP requests when device is connected to a Cellular connection. Defaults to false. Set true to allow autoSync only when device is connected to Wifi.
getter/setter pair
disableElasticity bool?
Disable automatic, speed-based distanceFilter scaling.
getter/setter pair
disableLocationAuthorizationAlert bool?
Disables automatic authorization alert when plugin detects the user has disabled location authorization.
getter/setter pair
disableMotionActivityUpdates bool?
Disable the plugin requesting "Motion & Fitness" (ios) or "Physical Activity" (android >= 10) authorization from the User.
getter/setter pair
disableProviderChangeRecord bool?
[Android-only] Disables the automatic insert of a location record into the SDK's SQLite database and subsequent HTTP upload if configured with Config.url. When a onProviderChange event fires, the Android SDK has traditionally recorded a location to show exactly when and where the state of location-services was changed (eg: Location-services disabled).
getter/setter pair
disableStopDetection bool?
Disable motion-activity related stop-detection.
getter/setter pair
distanceFilter double?
The minimum distance (measured in meters) a device must move horizontally before an update event is generated.
getter/setter pair
elasticityMultiplier double?
Controls the scale of automatic speed-based distanceFilter elasticity.
getter/setter pair
enableHeadless bool?
[Android only] Enables "Headless" operation allowing you to respond to events after you app has been terminated with stopOnTerminate:false.
getter/setter pair
enableTimestampMeta bool?
Enable extra timestamp meta data to be appended to each recorded location, including system-time.
getter/setter pair
extras Map<String, dynamic>?
Optional arbitrary key/values {} applied to each recorded location.
getter/setter pair
fastestLocationUpdateInterval int?
[Android only] Explicitly set the fastest interval for location updates, in milliseconds.
getter/setter pair
forceReloadOnBoot bool?
@deprecated: Banned in Android 10. Use enableHeadless instead
getter/setter pair
forceReloadOnGeofence bool?
@deprecated: Banned in Android 10. Use enableHeadless instead
getter/setter pair
forceReloadOnHeartbeat bool?
@deprecated: Banned in Android 10. Use enableHeadless instead
getter/setter pair
forceReloadOnLocationChange bool?
@deprecated: Banned in Android 10. Use enableHeadless instead
getter/setter pair
forceReloadOnMotionChange bool?
@deprecated: Banned in Android 10. Use enableHeadless instead Force launch your terminated App after a BackgroundGeolocation.onMotionChange event.
getter/setter pair
forceReloadOnSchedule bool?
@deprecated: Banned in Android 10. Use enableHeadless instead
getter/setter pair
foregroundService bool?
[Android only] Configure the plugin service to run as a more robust "Foreground Service".
getter/setter pair
geofenceInitialTriggerEntry bool?
When a device is already within a just-created geofence, fire the enter transition immediately.
getter/setter pair
geofenceModeHighAccuracy bool?
[Android only] Enable high-accuracy for geofence-only mode (See BackgroundGeolocation.startGeofences).
getter/setter pair
geofenceProximityRadius int?
The radius around current location to query for geofences to activate monitoring upon.
getter/setter pair
geofenceTemplate String?
Optional custom template for rendering geofence JSON request data in HTTP requests.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, dynamic>?
Optional HTTP headers applied to each HTTP request.
getter/setter pair
heartbeatInterval int?
Controls the rate (in seconds) the BackgroundGeolocation.onHeartbeat event will fire.
getter/setter pair
httpRootProperty String?
The root property of the JSON schema where location-data will be attached.
getter/setter pair
httpTimeout int?
HTTP request timeout in milliseconds.
getter/setter pair
isMoving bool?
Configure the initial tracking-state after BackgroundGeolocation.start is called.
getter/setter pair
locationAuthorizationAlert Map<String, dynamic>?
[iOS only] Controls the text-elements of the plugin's location-authorization dialog.
getter/setter pair
locationAuthorizationRequest String?
Defines the desired location-authorization request you wish for the user to authorize:
getter/setter pair
locationsOrderDirection String?
Controls the order that locations are selected from the database (and uploaded to your server).
getter/setter pair
locationTemplate String?
Optional custom template for rendering location JSON request data in HTTP requests.
getter/setter pair
locationTimeout int?
The default timeout in seconds when requesting a location before the SDK gives up and fires a LocationError.
getter/setter pair
locationUpdateInterval int?
[Android only] Set the desired interval for active location updates, in milliseconds.
getter/setter pair
logLevel int?
Controls the volume of recorded events in the plugin's logging database.
getter/setter pair
logMaxDays int?
Maximum number of days to persist a log-entry in database.
getter/setter pair
maxBatchSize int?
Controls the number of records attached to each batch HTTP request.
getter/setter pair
maxDaysToPersist int?
Maximum number of days to store a geolocation in plugin's SQLite database.
getter/setter pair
maxMonitoredGeofences int?
The maximum number of geofences to monitor at-a-time, overriding the platform default (iOS: 20; Android 100). NOTE: This option is for specialized use-cases where you wish to monitor LESS THAN the platform maximum. This option should generally not be used.
getter/setter pair
maxRecordsToPersist int?
Maximum number of records to persist in plugin's SQLite database.
getter/setter pair
method String?
The HTTP method to use when creating an HTTP request to your configured url.
getter/setter pair
minimumActivityRecognitionConfidence int?
The minimum motion-activity confidence to conclude a device is moving.
getter/setter pair
motionTriggerDelay int?
[Android only] Optionally add a delay in milliseconds to trigger Android into the moving state when Motion API reports the device is moving (eg: on_foot, in_vehicle)
getter/setter pair
notification Notification?
(Android only) Configure the persistent foreground notification.
getter/setter pair
notificationChannelName String?
@deprecated. Use Notification.channelName
getter/setter pair
notificationColor String?
@deprecated. Use Notification.color.
getter/setter pair
notificationLargeIcon String?
@deprecated. Use Notification.largeIcon.
getter/setter pair
notificationPriority int?
@deprecated. Use Notification.priority.
getter/setter pair
notificationSmallIcon String?
@deprecated. Use Notification.smallIcon.
getter/setter pair
notificationText String?
@deprecated. Use Notification.text.
getter/setter pair
notificationTitle String?
@deprecated. Use Notification.title.
getter/setter pair
params Map<String, dynamic>?
Optional HTTP params appended to the JSON body of each HTTP request.
getter/setter pair
pausesLocationUpdatesAutomatically bool?
[iOS only] Configure iOS location API to never automatically turn off.
getter/setter pair
persistMode int?
Allows you to specify which events to persist to the SDK's internal database: locations | geofences | all (default).
getter/setter pair
preventSuspend bool?
[iOS only] Prevent iOS from suspending your application in the background after location-services have been switched off.
getter/setter pair
reset bool?
Forces BackgroundGeolocation.ready to apply supplied Config with each application launch.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schedule List<String>?
Configures an automated, cron-like schedule for the plugin to BackgroundGeolocation.start / BackgroundGeolocation.stop tracking at pre-defined times.
getter/setter pair
scheduleUseAlarmManager bool?
Android only Force the Android scheduler to use AlarmManager (more precise) instead of JobScheduler. Defaults to false.
getter/setter pair
showsBackgroundLocationIndicator bool?
[iOS Only] A Boolean indicating whether the status bar changes its appearance when an app uses location services in the background.
getter/setter pair
speedJumpFilter int?
Experimental filter to ignore anomalous locations that suddenly jump an unusual distance from last. The SDK will calculate an apparent speed and distance relative to last known location. If the location suddenly teleports from last location, it will be ignored.
getter/setter pair
startOnBoot bool?
Controls whether to resume location-tracking after device is rebooted.
getter/setter pair
stationaryRadius double?
[iOS only] The minimum distance the device must move beyond the stationary location for aggressive background-tracking to engage.
getter/setter pair
stopAfterElapsedMinutes int?
Automatically BackgroundGeolocation.stop tracking after x minutes.
getter/setter pair
stopDetectionDelay int?
[iOS only] Allows the iOS stop-detection system to be delayed from activating.
getter/setter pair
stopOnStationary bool?
Automatically BackgroundGeolocation.stop when the stopTimeout elapses.
getter/setter pair
stopOnTerminate bool?
Controls whether to continue location-tracking after application is terminated.
getter/setter pair
stopTimeout int?
Minutes to wait in moving state with no movement before considering the device stationary.
getter/setter pair
transistorAuthorizationToken TransistorAuthorizationToken?
Convenience option to automatically configures the SDK to upload locations to the Transistor Software demo server at http://tracker.transistorsoft.com (or your own local instance of background-geolocation-console)
getter/setter pair
triggerActivities String?
[Android-only] Configures a comma-separated list of motion-activities which are allow to trigger location-tracking.
getter/setter pair
url String?
Your server url where you wish to POST locations to.
getter/setter pair
useSignificantChangesOnly bool?
Set true in order to disable constant background-tracking. Locations will be recorded only periodically.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String key, dynamic value) Config
toMap() Map?
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

deviceParams Future<Map<String, dynamic>>
@deprecated: Use transistorAuthorizationToken
no setter