#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:
Brad Leege
2015-04-07 15:53:17 -05:00
parent 482275f978
commit e86597011f
2 changed files with 18 additions and 0 deletions

View File

@@ -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

View File

@@ -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];
}