#1216 - Added test usage of pausing / resuming Metrics to simulate app entering background mode and no other location manager running. Added paused state checking to pauseMetricsCollection and resumeMetricsCollection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#import "MBXAppDelegate.h"
|
||||
#import "MBXViewController.h"
|
||||
#import <mbgl/ios/MGLMapboxEvents.h>
|
||||
|
||||
@implementation MBXAppDelegate
|
||||
|
||||
@@ -12,4 +13,15 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
[MGLMapboxEvents resumeMetricsCollection];
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
[MGLMapboxEvents pauseMetricsCollection];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -230,6 +230,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
//
|
||||
+ (void) pauseMetricsCollection {
|
||||
assert([[NSThread currentThread] isMainThread]);
|
||||
if ([MGLMapboxEvents sharedManager].isPaused) {
|
||||
return;
|
||||
}
|
||||
[MGLMapboxEvents sharedManager].isPaused = YES;
|
||||
[MGLMetricsLocationManager stopUpdatingLocation];
|
||||
}
|
||||
@@ -238,6 +241,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
//
|
||||
+ (void) resumeMetricsCollection {
|
||||
assert([[NSThread currentThread] isMainThread]);
|
||||
if (![MGLMapboxEvents sharedManager].isPaused) {
|
||||
return;
|
||||
}
|
||||
[MGLMapboxEvents sharedManager].isPaused = NO;
|
||||
[MGLMetricsLocationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user