File tree Expand file tree Collapse file tree 7 files changed +26
-1
lines changed Expand file tree Collapse file tree 7 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
- ## 1.1.0 - 14-10 -2021
1
+ ## 1.1.0 - xx-xx -2021
2
2
#Added
3
3
- Added more options to android config to specify update interval
4
4
- Added iOS specific options to control activity type and/or distance filter
5
+ - Added iOS specific options to restart the tracking after killing the app
5
6
- Added option to Android specific options to only get updates every x meters
6
7
7
8
## 1.0.2 - 22-06-2021
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Future<void> main() async {
16
16
await BackgroundLocationTrackerManager .initialize (
17
17
_backgroundCallback,
18
18
config: const BackgroundLocationTrackerConfig (
19
+ loggingEnabled: true ,
19
20
androidConfig: AndroidConfig (
20
21
notificationIcon: 'explore' ,
21
22
trackingInterval: Duration (seconds: 4 ),
@@ -24,6 +25,7 @@ Future<void> main() async {
24
25
iOSConfig: IOSConfig (
25
26
activityType: ActivityType .FITNESS ,
26
27
distanceFilterMeters: 5 ,
28
+ restartAfterKill: true ,
27
29
),
28
30
),
29
31
);
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ public class ForegroundChannel : NSObject {
51
51
let loggingEnabledKey = " logging_enabled "
52
52
let activityTypeKey = " ios_activity_type "
53
53
let distanceFilterKey = " ios_distance_filter "
54
+ let restartAfterKillKey = " ios_restart_after_kill "
54
55
let map = call. arguments as? [ String : Any ]
55
56
guard let callbackDispatcherHandle = map ? [ callBackHandleKey] else {
56
57
result ( false )
@@ -60,6 +61,7 @@ public class ForegroundChannel : NSObject {
60
61
61
62
let loggingEnabled : Bool = map ? [ loggingEnabledKey] as? Bool ?? false
62
63
SharedPrefsUtil . saveLoggingEnabled ( loggingEnabled)
64
+ SharedPrefsUtil . saveRestartAfterKillEnabled ( map ? [ restartAfterKillKey] as? Bool ?? false )
63
65
64
66
let activityType : CLActivityType
65
67
switch ( map ? [ activityTypeKey] as? String ?? " AUTOMOTIVE " ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ struct SharedPrefsUtil {
12
12
13
13
private static let KEY_CALLBACK_HANDLER = " background.location.tracker.manager.CALLBACK_DISPATCHER_HANDLE_KEY "
14
14
private static let KEY_IS_TRACKING = " background.location.tracker.manager.IS_TRACKING "
15
+ private static let KEY_IS_RESTART_AFTER_KILL = " background.location.tracker.manager.RESTART_AFTER_KILL "
15
16
private static let KEY_LOGGING_ENABLED = " background.location.tracker.manager.LOGGIN_ENABLED "
16
17
private static let KEY_DISTANCE_FILTER = " background.location.tracker.manager.DISTANCE_FILTER "
17
18
private static let KEY_ACTIVITY_TYPE = " background.location.tracker.manager.KEY_ACTIVITY_TYPE "
@@ -38,6 +39,14 @@ struct SharedPrefsUtil {
38
39
return getValue ( for: SharedPrefsUtil . KEY_IS_TRACKING) ?? false
39
40
}
40
41
42
+ static func restartAfterKill( ) -> Bool {
43
+ return getValue ( for: SharedPrefsUtil . KEY_IS_RESTART_AFTER_KILL) ?? false
44
+ }
45
+
46
+ static func saveRestartAfterKillEnabled( _ isRestartEnabled: Bool ) {
47
+ store ( isRestartEnabled, key: SharedPrefsUtil . KEY_IS_RESTART_AFTER_KILL)
48
+ }
49
+
41
50
static func saveLoggingEnabled( _ isLoggingEnabled: Bool ) {
42
51
store ( isLoggingEnabled, key: SharedPrefsUtil . KEY_LOGGING_ENABLED)
43
52
}
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ extension SwiftBackgroundLocationTrackerPlugin: FlutterPlugin {
36
36
let instance = SwiftBackgroundLocationTrackerPlugin ( )
37
37
registrar. addMethodCallDelegate ( instance, channel: methodChannel)
38
38
registrar. addApplicationDelegate ( instance)
39
+
40
+ if ( SharedPrefsUtil . isTracking ( ) && SharedPrefsUtil . restartAfterKill ( ) ) {
41
+ instance. locationManager. delegate = instance
42
+ instance. locationManager. startUpdatingLocation ( )
43
+ }
39
44
}
40
45
41
46
public func handle( _ call: FlutterMethodCall , result: @escaping FlutterResult ) {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class ForegroundChannel {
41
41
'android_distance_filter' : config.androidConfig.distanceFilterMeters,
42
42
'ios_activity_type' : _activityTypeString (config.iOSConfig.activityType),
43
43
'ios_distance_filter' : config.iOSConfig.distanceFilterMeters,
44
+ 'ios_restart_after_kill' : config.iOSConfig.restartAfterKill,
44
45
},
45
46
);
46
47
}
Original file line number Diff line number Diff line change @@ -10,13 +10,18 @@ class IOSConfig {
10
10
/// The type of activity, default to [ActivityType.AUTOMOTIVE]
11
11
final ActivityType activityType;
12
12
13
+ /// Restart the location tracker when the app is recreated
14
+ /// after it has been killed by the user. Defaults to false
15
+ final bool restartAfterKill;
16
+
13
17
/// The distance in meters that should be moved before updates are sent.
14
18
/// Defaults to no filter (null)
15
19
final int ? distanceFilterMeters;
16
20
17
21
const IOSConfig ({
18
22
this .activityType = ActivityType .AUTOMOTIVE ,
19
23
this .distanceFilterMeters,
24
+ this .restartAfterKill = false ,
20
25
});
21
26
}
22
27
You can’t perform that action at this time.
0 commit comments