Setup¶
Installation¶
Add the dependency to pubspec.yaml:
Then fetch:
Configure your license¶
Purchase a license
The SDK requires a license for release builds. Debug builds work without one. Purchase at transistorsoft.com.
iOS — Info.plist¶
Android — AndroidManifest.xml¶
<application>
<meta-data
android:name="com.transistorsoft.locationmanager.license"
android:value="YOUR_LICENSE_KEY_JWT" />
</application>
iOS Setup¶
Podfile¶
Add :linkage => :static to your target in ios/Podfile:
Then run:
Background Modes¶
In Xcode, select your target → Signing & Capabilities → + Capability → Background Modes. Enable:
- [x] Location updates
- [x] Background fetch
- [x] Audio (optional — enables debug sound FX)
Info.plist¶
<!-- License key -->
<key>TSLocationManagerLicense</key>
<string>YOUR_LICENSE_KEY_JWT</string>
<!-- Background modes -->
<key>UIBackgroundModes</key>
<array>
<string>location</string>
<string>fetch</string>
<string>processing</string>
<string>audio</string>
</array>
<!-- Background task identifier -->
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.transistorsoft.fetch</string>
</array>
<!-- Location usage descriptions -->
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App requires location access at all times for background tracking.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App requires location access while in use.</string>
<key>NSMotionUsageDescription</key>
<string>Motion detection helps determine when the device is stationary.</string>
Android Setup¶
Gradle ext vars¶
The plugin reads two optional ext vars from your root project. Set them in android/build.gradle to pin specific versions:
| Variable | Default | Description |
|---|---|---|
playServicesLocationVersion |
21.3.0 |
com.google.android.gms:play-services-location version. Browse: maven.google.com |
tslocationmanagerVersion |
4.0.+ |
Transistor Android SDK version. Browse: central.sonatype.com |
android/app/build.gradle / android/app/build.gradle.kts¶
AndroidManifest.xml¶
<application>
<meta-data
android:name="com.transistorsoft.locationmanager.license"
android:value="YOUR_LICENSE_KEY_JWT" />
</application>
Example¶
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
// Use the 'bg' namespace to avoid conflicts with Flutter's own Location/State types.
bg.BackgroundGeolocation.ready(bg.Config(
geolocation: bg.GeoConfig(
desiredAccuracy: bg.DesiredAccuracy.high,
distanceFilter: 10.0,
),
app: bg.AppConfig(
stopOnTerminate: false,
startOnBoot: true,
),
logger: bg.LoggerConfig(
debug: true,
logLevel: bg.LogLevel.verbose,
),
)).then((bg.State state) {
if (!state.enabled) {
bg.BackgroundGeolocation.start();
}
});