summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-05-12 11:04:14 -0500
committerBrad Leege <bleege@gmail.com>2015-05-12 11:04:14 -0500
commit3391d8f6d843ab57b8c1b1733530caf2a71f9066 (patch)
tree65551838054dd8bca12328fc17626c0c3de05b3e /platform
parent106212158630c1fd15aec2225bcbb01268c8bae0 (diff)
parent87551c6d0e189cd6d98cc75e93ba4f0f176a3464 (diff)
downloadqtlocation-mapboxgl-3391d8f6d843ab57b8c1b1733530caf2a71f9066.tar.gz
Merge pull request #1520 from mapbox/1516-opt-out-checking
Explicit Opt Out Checking
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLAccountManager.m10
-rw-r--r--platform/ios/MGLMapboxEvents.m16
2 files changed, 20 insertions, 6 deletions
diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m
index b1a80fd6a7..09bfb3db23 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 sharedInstance].showsOptOutInApp = showsOptOut;
+}
+
++ (BOOL) mapboxMetricsEnabledSettingShownInApp {
+ return [MGLAccountManager sharedInstance].showsOptOutInApp;
+}
+
+ (void) setAccessToken:(NSString *) accessToken {
[[MGLAccountManager sharedInstance] setAccessToken:accessToken];
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index 3a6559b766..244928f95c 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -9,6 +9,7 @@
#import "NSProcessInfo+MGLAdditions.h"
#import "NSBundle+MGLAdditions.h"
#import "NSException+MGLAdditions.h"
+#import "MGLAccountManager.m"
#include <sys/sysctl.h>
@@ -117,11 +118,13 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
self = [super init];
if (self) {
- // Put Settings bundle into memory
- 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 via the Settings.bundle or in the app itself which must be noted via setting +[MGLAccountManager setShowsOptOutInApp:YES]");
+
// 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"]];
@@ -133,9 +136,10 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
[defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key];
}
}
-
+
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister];
}
+
_appBundleId = [[NSBundle mainBundle] bundleIdentifier];
NSString *uniqueID = [[NSProcessInfo processInfo] globallyUniqueString];
_serialQueue = dispatch_queue_create([[NSString stringWithFormat:@"%@.%@.events.serial", _appBundleId, uniqueID] UTF8String], DISPATCH_QUEUE_SERIAL);