flutter_background_geolocation 1.0.0-rc.1 flutter_background_geolocation: ^1.0.0-rc.1 copied to clipboard
The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
[1.0.0-rc.1] - 2019-03-20 #
Breaking Changes #
- [Changed] The license format has changed. New
1.0.0
licenses are now available for customers in the product dashboard.
Fixes #
- [Fixed] iOS missing native
destroyLog
implementation (thanks to @joserocha3) - [Fixed] Missing Dart implementation for
requestPermission
method (thanks to @joserocha3) - [Fixed] Logic bugs in MotionActivity triggering between stationary / moving states.
- [Fixed] List.map Bug in Dart api
addGeofences
.
New Features #
- [Added] Android implementation for
useSignificantChangesOnly
Config option. Will request Android locations without the persistent foreground service. You will receive location updates only a few times per hour:useSignificantChangesOnly: true
:
useSignificantChangesOnly: false
:
-
[Added] Android now implements a "stationary geofence", just like iOS. It currently acts as a secondary triggering mechanism along with the current motion-activity API. You will hear the "zap" sound effect when it triggers. This also has the fortunate consequence of allowing mock-location apps (eg: Lockito) of being able to trigger tracking automatically.
-
[Added] The SDK detects mock locations and skips trigging the
stopTimeout
system, improving location simulation workflow. -
[Added] Android-only Config option
geofenceModeHighAccuracy
for more control over geofence triggering responsiveness. Runs a foreground-service during geofences-only mode (#startGeofences
). This will, of course, consume more power.
await BackgroundGeolocation.ready(Config
geofenceModeHighAccuracy: true,
desiredAccuracy: Config.DESIRED_ACCURACY_MEDIUM,
locationUpdateInterval: 5000,
distanceFilter: 50
));
BackgroundGeolocation.startGeofences();
- [Added] Android implementation of
startBackgroundTask
/stopBackgroundTask
. This implementation uses a foreground-service. I've tried using Android'sJobService
but these tasks are queued by the OS and run only periodically.
// an Android foreground-service has just launched (in addition to its persistent notification).
int taskId = await BackgroundGeolocation.startBackgroundTask();
// Do any work you like -- it's guaranteed to run, regardless of background/terminated.
// Your task has exactly 30s to do work before the service auto-stops itself.
// Execute an HTTP request to test an async operation.
String url = "http://tracker.transistorsoft.com/devices?company_token=$_username";
String result = await http.read(url).then((String result) {
print("[http test] success: $result");
// Terminate the foreground-service.
BackgroundGeolocation.stopBackgroundTask(taskId);
}).catchError((dynamic error) {
print("[http test] failed: $error");
// Always be sure to stop your tasks, just like iOS.
BackgroundGeolocation.stopBackgroundTask(taskId);
});
Logging for background-tasks looks like this (when you see an hourglass, a foreground-service is active)
[BackgroundTaskManager onStartJob] ⏳ startBackgroundTask: 6
.
.
.
[BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 6
- [Added] New custom Android debug sound FX. More documentation will be added to the docs but here's a basic description from the code:
public static final String LOCATION_RECORDED = OOOOIII;
public static final String LOCATION_SAMPLE = CLICK_TAP_DONE;
public static final String LOCATION_ERROR = DIGI_WARN;
public static final String MOTIONCHANGE_FALSE = MARIMBA_DROP;
public static final String MOTIONCHANGE_TRUE = CHIME_SHORT_CHORD_UP;
public static final String STATIONARY_GEOFENCE_EXIT = ZAP_FAST;
public static final String STOP_TIMER_ON = CHIME_BELL_CONFIRM;
public static final String STOP_TIMER_OFF = BELL_DING_POP;
public static final String HEARTBEAT = PEEP_NOTE;
public static final String GEOFENCE_ENTER = BEEP_TRIP_UP_DRY;
public static final String GEOFENCE_DWELL = BEEP_TRIP_UP_ECHO;
public static final String GEOFENCE_EXIT = BEEP_TRIP_DRY;
public static final String WARNING = DIGI_WARN;
public static final String ERROR = MUSIC_TIMPANI_ERROR;
⚠️ These debug sound FX consume about 1.4MB in the plugin's tslocationmanager.aar
. These assets can easily be stripped in your release
builds by adding the following gradle task to your app/build.gradle
(I'm working on an automated solution within the context of the plugin's build.gradle
; so far, no luck). Big thanks to @mikehardy.
/**
* Purge flutter_background_geolocation debug sounds from release build.
*/
def purgeBackgroundGeolocationDebugResources(applicationVariants) {
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
variant.mergeResources.doLast {
delete(fileTree(dir: variant.mergeResources.outputDir, includes: ['raw_tslocationmanager*']))
}
}
}
}
android {
//Remove debug sounds from background_geolocation plugin
purgeBackgroundGeolocationDebugResources(applicationVariants)
compileSdkVersion rootProject.ext.compileSdkVersion
.
.
.
}
Removed #
- [Changed] Removed Android config option
activityRecognitionInterval
. The Android SDK now uses the more modern ActivityTransistionClient API which is a higher level wrapper for the traditional ActivityReconitionClient.AcitvityTransitionClient
does not accept a pollinginterval
, thusactiivtyRecognitionInterval
is now unused. Also,ActivityTransitionClient
emits similaron_foot
,in_vehicle
events but no longer provides aconfidence
, thusconfidence
is now reported always as100
. If you've been implementing your own custom triggering logic based uponconfidence
, it's now pointless. TheActivityTransitionClient
will open doors for new features based upon transitions between activity states.
╔═════════════════════════════════════════════
║ Motion Transition Result
╠═════════════════════════════════════════════
╟─ 🔴 EXIT: walking
╟─ 🎾 ENTER: still
╚═════════════════════════════════════════════
Maintenance #
- [Changed] Update
android-permissions
dependency to0.1.8
.