Skip to content

Commit

Permalink
feature: implement config.stopOnTerminate using startMonitoringSignif…
Browse files Browse the repository at this point in the history
…icantLocationChanges
  • Loading branch information
Stanislav Mayorov authored and mauron85 committed Jan 8, 2019
1 parent 5734e71 commit 5149178
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions BackgroundGeolocation/MAURDistanceFilterLocationProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ @implementation MAURDistanceFilterLocationProvider {
BOOL isUpdatingLocation;
BOOL isAcquiringStationaryLocation;
BOOL isAcquiringSpeed;
BOOL isStarted;

CLCircularRegion *stationaryRegion;
NSDate *stationarySince;
Expand All @@ -58,6 +59,7 @@ - (instancetype) init
isAcquiringStationaryLocation = NO;
isAcquiringSpeed = NO;
stationaryRegion = nil;
isStarted = NO;
}

return self;
Expand Down Expand Up @@ -142,7 +144,9 @@ - (BOOL) onStart:(NSError * __autoreleasing *)outError
}

[self switchMode:MAURForegroundMode];


isStarted = YES;

return YES;
}

Expand All @@ -156,7 +160,9 @@ - (BOOL) onStop:(NSError * __autoreleasing *)outError
[self stopUpdatingLocation];
[self stopMonitoringSignificantLocationChanges];
[self stopMonitoringForRegion];


isStarted = NO;

return YES;
}

Expand Down Expand Up @@ -415,6 +421,13 @@ - (void) startUpdatingLocation
}
}

- (void) onTerminate
{
if (isStarted && !_config.stopOnTerminate) {
[locationManager startMonitoringSignificantLocationChanges];
}
}

- (void) startMonitoringSignificantLocationChanges
{
[locationManager startMonitoringSignificantLocationChanges];
Expand Down
5 changes: 4 additions & 1 deletion BackgroundGeolocation/MAURRawLocationProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ @implementation MAURRawLocationProvider {

BOOL isStarted;
MAURLocationManager *locationManager;

MAURConfig *_config;
}

- (instancetype) init
Expand All @@ -39,6 +41,7 @@ - (void) onCreate {
- (BOOL) onConfigure:(MAURConfig*)config error:(NSError * __autoreleasing *)outError
{
DDLogVerbose(@"%@ configure", TAG);
_config = config;

locationManager.pausesLocationUpdatesAutomatically = [config pauseLocationUpdates];
locationManager.activityType = [config decodeActivityType];
Expand Down Expand Up @@ -79,7 +82,7 @@ - (BOOL) onStop:(NSError * __autoreleasing *)outError

- (void) onTerminate
{
if (isStarted) {
if (isStarted && !_config.stopOnTerminate) {
[locationManager startMonitoringSignificantLocationChanges];
}
}
Expand Down

0 comments on commit 5149178

Please sign in to comment.