diff options
-rw-r--r-- | include/mbgl/ios/MGLMapboxEvents.h | 2 | ||||
-rw-r--r-- | include/mbgl/ios/MGLMetricsLocationManager.h | 4 | ||||
-rw-r--r-- | ios/MapboxGL.podspec | 17 | ||||
-rw-r--r-- | ios/app/MBXAppDelegate.m | 23 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 34 |
5 files changed, 71 insertions, 9 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/include/mbgl/ios/MGLMetricsLocationManager.h b/include/mbgl/ios/MGLMetricsLocationManager.h index 7281d05010..5f3b568187 100644 --- a/include/mbgl/ios/MGLMetricsLocationManager.h +++ b/include/mbgl/ios/MGLMetricsLocationManager.h @@ -2,8 +2,10 @@ @interface MGLMetricsLocationManager : NSObject -// This method can be called from any thread. +// These methods can be called from any thread. // + (instancetype)sharedManager; ++ (void) startUpdatingLocation; ++ (void) stopUpdatingLocation; @end diff --git a/ios/MapboxGL.podspec b/ios/MapboxGL.podspec index b474f7c9e7..72f413ef6e 100644 --- a/ios/MapboxGL.podspec +++ b/ios/MapboxGL.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'MapboxGL' - m.version = '0.1.0' + m.version = '0.2.9' m.summary = 'Open source vector map solution for iOS with full styling capabilities.' m.description = 'Open source OpenGL-based vector map solution for iOS with full styling capabilities and Cocoa bindings.' @@ -11,23 +11,24 @@ Pod::Spec.new do |m| m.screenshot = 'https://raw.githubusercontent.com/mapbox/mapbox-gl-native/master/ios/screenshot.png' m.social_media_url = 'https://twitter.com/mapbox' - m.source = { :http => "http://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/mapbox-gl-ios-#{m.version.to_s}.zip" } + m.source = { + :http => "http://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-gl-ios-#{m.version.to_s}.zip", + :flatten => true + } m.platform = :ios m.ios.deployment_target = '7.0' - m.source_files = 'Headers/*.h' - m.requires_arc = true + m.preserve_paths = '**' + m.source_files = 'Headers/*.h' m.resource_bundle = { 'MapboxGL' => 'MapboxGL.bundle/*' } + m.vendored_library = 'libMapboxGL.a' - m.frameworks = 'CoreLocation', 'CoreTelephony', 'GLKit', 'ImageIO', 'MobileCoreServices', 'QuartzCore', 'SystemConfiguration' + m.frameworks = 'CoreLocation', 'CoreTelephony', 'GLKit', 'ImageIO', 'MobileCoreServices', 'QuartzCore', 'SystemConfiguration' m.libraries = 'c++', 'sqlite3', 'z' - - m.vendored_library = 'libMapboxGL.a' - m.xcconfig = { 'OTHER_CPLUSPLUSFLAGS' => '-std=gnu++11 -stdlib=libc++' } end diff --git a/ios/app/MBXAppDelegate.m b/ios/app/MBXAppDelegate.m index f0541b9971..f2ef69ec63 100644 --- a/ios/app/MBXAppDelegate.m +++ b/ios/app/MBXAppDelegate.m @@ -1,5 +1,6 @@ #import "MBXAppDelegate.h" #import "MBXViewController.h" +#import <mbgl/ios/MGLMapboxEvents.h> @implementation MBXAppDelegate @@ -12,4 +13,26 @@ return YES; } +/** +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Example of how to resume Metrics Collection + + // Reasons for needing to resume: + // 1. In UIBackground and app starts listening for Location Updates where it previously had not been listening. + // 2. App is entering foreground where it had called pauseMetricsCollection. + [MGLMapboxEvents resumeMetricsCollection]; +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Example of how to pause Metrics Collection + + // Reason for needing to pause: + // 1. Either entering or already in UIBackground and app stops listening for Location Updates + // via any CLLocationManager instance it may have. + [MGLMapboxEvents pauseMetricsCollection]; +} +*/ + @end diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 2dfecbd778..346bd70aca 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,28 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [MGLMapboxEvents sharedManager].appVersion = appVersion; } +// Must be called from the main thread. +// ++ (void) pauseMetricsCollection { + assert([[NSThread currentThread] isMainThread]); + if ([MGLMapboxEvents sharedManager].isPaused) { + return; + } + [MGLMapboxEvents sharedManager].isPaused = YES; + [MGLMetricsLocationManager stopUpdatingLocation]; +} + +// Must be called from the main thread. +// ++ (void) resumeMetricsCollection { + assert([[NSThread currentThread] isMainThread]); + if (![MGLMapboxEvents sharedManager].isPaused) { + return; + } + [MGLMapboxEvents sharedManager].isPaused = NO; + [MGLMetricsLocationManager startUpdatingLocation]; +} + // Can be called from any thread. Can be called rapidly from // the UI thread, so performance is paramount. // @@ -247,6 +276,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return; } + // Metrics Collection Has Been Paused + if (_isPaused) { + return; + } + if (!event) return; NSMutableDictionary *evt = [[NSMutableDictionary alloc] initWithDictionary:attributeDictionary]; |