diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-05-12 16:09:10 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-05-12 16:09:10 -0700 |
commit | b1992a45167e5c434b384f6ef9e5281f637d0642 (patch) | |
tree | 5484523c942e917d83887282e246c9ae09a54fa2 /platform | |
parent | 54a703bcb21e567559caf691759bb207c611d776 (diff) | |
parent | 50d7add6b0edeaaf22a3a035d2bbff1c13a08669 (diff) | |
download | qtlocation-mapboxgl-b1992a45167e5c434b384f6ef9e5281f637d0642.tar.gz |
Merge branch 'master' into 1ec5-metrics-opt-way-out
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/MGLAccountManager.m | 10 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 15 |
2 files changed, 19 insertions, 6 deletions
diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m index ad1e93d29b..0539fb9dca 100644 --- a/platform/ios/MGLAccountManager.m +++ b/platform/ios/MGLAccountManager.m @@ -6,6 +6,7 @@ @interface MGLAccountManager() +@property (atomic) BOOL showsOptOutInApp; @property (atomic) NSString *accessToken; @end @@ -23,6 +24,7 @@ static MGLAccountManager *_sharedManager; if ( ! NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) { void (^setupBlock)() = ^{ _sharedManager = [[self alloc] init]; + _sharedManager.showsOptOutInApp = NO; }; if ( ! [[NSThread currentThread] isMainThread]) { dispatch_sync(dispatch_get_main_queue(), ^{ @@ -37,6 +39,14 @@ static MGLAccountManager *_sharedManager; return _sharedManager; } ++ (void) setMapboxMetricsEnabledSettingShownInApp:(BOOL)showsOptOut { + [MGLAccountManager sharedManager].showsOptOutInApp = showsOptOut; +} + ++ (BOOL) mapboxMetricsEnabledSettingShownInApp { + return [MGLAccountManager sharedManager].showsOptOutInApp; +} + + (void) setAccessToken:(NSString *) accessToken { [[MGLAccountManager sharedManager] setAccessToken:accessToken]; diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 89a13f7b56..66c23ec438 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -10,6 +10,7 @@ #import "NSProcessInfo+MGLAdditions.h" #import "NSBundle+MGLAdditions.h" #import "NSException+MGLAdditions.h" +#import "MGLAccountManager.m" #include <sys/sysctl.h> @@ -176,11 +177,13 @@ const NSTimeInterval MGLFlushInterval = 60; + (void)initialize { if (self == [MGLMapboxEvents class]) { - // Register defaults from DefaultValue entries in Settings.bundle plist. - NSString *appSettingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; - if(!appSettingsBundle) { - NSLog(@"Could not find Settings.bundle"); - } else { + if (! [MGLAccountManager mapboxMetricsEnabledSettingShownInApp]) { + // Opt Out is not configured in UI, so check for Settings.bundle + // Put Settings bundle into memory + NSString *appSettingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; + + NSAssert(appSettingsBundle, @"End users must be able to opt out of Metrics in your app, either inside Settings (via Settings.bundle) or inside this app. If you implement the opt-out control inside this app, disable this assertion by setting [MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:YES] before the app initializes any Mapbox GL classes."); + // Dynamic Settings.bundle loading based on: // http://stackoverflow.com/questions/510216/can-you-make-the-settings-in-settings-bundle-default-even-if-you-dont-open-the NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[appSettingsBundle stringByAppendingPathComponent:@"Root.plist"]]; @@ -192,7 +195,7 @@ const NSTimeInterval MGLFlushInterval = 60; [defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key]; } } - + [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister]; } } |