diff options
-rw-r--r-- | include/mbgl/ios/MGLMapboxEvents.h | 2 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h index e51371368d..2af3d8b168 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/include/mbgl/ios/MGLMapboxEvents.h @@ -29,6 +29,8 @@ extern NSString *const MGLEventGestureRotateStart; + (void) setToken:(NSString *)token; + (void) setAppName:(NSString *)appName; + (void) setAppVersion:(NSString *)appVersion; ++ (void) pauseMetricsCollection; ++ (void) resumeMetricsCollection; // You can call this method from any thread. Significant work will // be dispatched to a low-priority background queue and all diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 2dfecbd778..593a983904 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -71,6 +71,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; @property (atomic) NSDateFormatter *rfc3339DateFormatter; @property (atomic) CGFloat scale; + +// The isPaused state tracker is only ever accessed from the main thread. +// +@property (nonatomic) BOOL isPaused; + // The timer is only ever accessed from the main thread. // @property (nonatomic) NSTimer *timer; @@ -168,6 +173,8 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // Clear Any System TimeZone Cache [NSTimeZone resetSystemTimeZone]; [_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; + + _isPaused = NO; } return self; } @@ -219,6 +226,20 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [MGLMapboxEvents sharedManager].appVersion = appVersion; } +// Must be called from the main thread. +// ++ (void) pauseMetricsCollection { + assert([[NSThread currentThread] isMainThread]); + [MGLMapboxEvents sharedManager].isPaused = YES; +} + +// Must be called from the main thread. +// ++ (void) resumeMetricsCollection { + assert([[NSThread currentThread] isMainThread]); + [MGLMapboxEvents sharedManager].isPaused = NO; +} + // Can be called from any thread. Can be called rapidly from // the UI thread, so performance is paramount. // |