summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-21 01:49:53 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-05-21 01:49:53 -0700
commit70381d2705991b15a1861b3162f50aa56961343c (patch)
treeeb402d4df1de78d197df7dc16321454b7b31547d /platform
parent8a83c31e05b47c910d5862cb2ed34828fc491e40 (diff)
downloadqtlocation-mapboxgl-70381d2705991b15a1861b3162f50aa56961343c.tar.gz
Fixed up various Info.plist edge cases
Need to look in the main bundle for Info.plist settings, because the developer has no access to the framework’s Info.plist. Need to check MGLMapboxMetricsEnabledSettingShownInApp before MGLMapboxAccessToken; otherwise, `MGLMapboxEvents` inspects the Settings bundle plist before MGLMapboxMetricsEnabledSettingShownInApp is even checked.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLAccountManager.m8
-rw-r--r--platform/ios/MGLMapboxEvents.m5
2 files changed, 8 insertions, 5 deletions
diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m
index 2f246b7d91..03a90c31b9 100644
--- a/platform/ios/MGLAccountManager.m
+++ b/platform/ios/MGLAccountManager.m
@@ -15,13 +15,15 @@
@implementation MGLAccountManager
+ (void)load {
- // Read initial configuration from Info.plist.
- NSBundle *bundle = [NSBundle bundleForClass:self];
- self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
+ // Read the initial configuration from Info.plist. The shown-in-app setting
+ // preempts the Settings bundle check in -[MGLMapboxEvents init] triggered
+ // by setting the access token.
+ NSBundle *bundle = [NSBundle mainBundle];
NSNumber *shownInAppNumber = [bundle objectForInfoDictionaryKey:@"MGLMapboxMetricsEnabledSettingShownInApp"];
if (shownInAppNumber) {
[MGLAccountManager sharedManager].mapboxMetricsEnabledSettingShownInApp = [shownInAppNumber boolValue];
}
+ self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
}
// Can be called from any thread.
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index a0e771ad07..1079899ced 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -177,7 +177,7 @@ const NSTimeInterval MGLFlushInterval = 60;
+ (void)initialize {
if (self == [MGLMapboxEvents class]) {
- NSBundle *bundle = [NSBundle bundleForClass:self];
+ NSBundle *bundle = [NSBundle mainBundle];
NSNumber *accountTypeNumber = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccountType"];
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"MGLMapboxAccountType": accountTypeNumber ? accountTypeNumber : @0,
@@ -198,7 +198,8 @@ const NSTimeInterval MGLFlushInterval = 60;
self = [super init];
if (self) {
- if (! [MGLAccountManager mapboxMetricsEnabledSettingShownInApp]) {
+ if (! [MGLAccountManager mapboxMetricsEnabledSettingShownInApp] &&
+ [[NSUserDefaults standardUserDefaults] integerForKey:@"MGLMapboxAccountType"] == 0) {
// Opt Out is not configured in UI, so check for Settings.bundle
// Put Settings bundle into memory
id defaultEnabledValue;