summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2019-05-14 15:39:24 -0700
committerJason Wray <friedbunny@users.noreply.github.com>2019-05-15 11:22:04 -0700
commit7f45afaedd42f214f9967223ec747e9cd142632e (patch)
treec85826280ced03a572fc02e54685d5bec5d15589
parent66e896fab930f995556865ec19b9553c7b57d1cf (diff)
downloadqtlocation-mapboxgl-7f45afaedd42f214f9967223ec747e9cd142632e.tar.gz
Revert "[ios] CP #14467 - Enable/Disable sku token handling (#14502)"
This reverts commit 4920cec4d9b5abf7a8d7a56924e07b562e10c40b.
-rw-r--r--platform/darwin/src/MGLAccountManager.m43
-rw-r--r--platform/darwin/src/MGLAccountManager_Private.h3
-rw-r--r--platform/darwin/src/http_file_source.mm15
-rw-r--r--platform/ios/src/MGLMapboxEvents.m5
-rw-r--r--platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h6
-rw-r--r--platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.abin62456 -> 48440 bytes
6 files changed, 16 insertions, 56 deletions
diff --git a/platform/darwin/src/MGLAccountManager.m b/platform/darwin/src/MGLAccountManager.m
index edcfbbcdf0..0566605323 100644
--- a/platform/darwin/src/MGLAccountManager.m
+++ b/platform/darwin/src/MGLAccountManager.m
@@ -10,8 +10,6 @@
#import "MBXSKUToken.h"
#endif
-static BOOL _MGLAccountsSDKEnabled;
-
@interface MGLAccountManager ()
@property (atomic) NSString *accessToken;
@@ -21,6 +19,7 @@ static BOOL _MGLAccountsSDKEnabled;
@property (atomic) NSString *skuToken;
@property (atomic) NSDate *skuTokenExpiration;
#endif
+
@end
@implementation MGLAccountManager
@@ -33,7 +32,7 @@ static BOOL _MGLAccountsSDKEnabled;
if (accessToken.length) {
self.accessToken = accessToken;
}
-
+
NSString *apiBaseURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAPIBaseURL"];
// If apiBaseURL is not a valid URL, [NSURL URLWithString:] will be `nil`.
@@ -42,17 +41,7 @@ static BOOL _MGLAccountsSDKEnabled;
}
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- // TODO: Use MGL_OBJC_DYNAMIC_CAST (that requires moving the macro, where it
- // doesn't require a C++ header)
- NSNumber *accountsSDKNumber = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAccountsSDKEnabled"];
- if ([accountsSDKNumber isKindOfClass:[NSNumber class]]) {
- _MGLAccountsSDKEnabled = ((NSNumber*)accountsSDKNumber).boolValue;
- }
-
- if (self.isAccountsSDKEnabled) {
- self.skuToken = MBXSKUToken.mapsToken;
- }
-
+ self.skuToken = [MBXSKUToken skuToken];
#endif
}
@@ -112,31 +101,15 @@ static BOOL _MGLAccountsSDKEnabled;
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
-+ (BOOL)isAccountsSDKEnabled {
- return _MGLAccountsSDKEnabled;
-}
-
+ (void)setSkuToken:(NSString *)skuToken {
- if (MGLAccountManager.isAccountsSDKEnabled) {
- NSTimeInterval oneHour = 60 * 60; // TODO: make this const
- MGLAccountManager.sharedManager.skuTokenExpiration = [NSDate dateWithTimeIntervalSinceNow:oneHour];
- MGLAccountManager.sharedManager.skuToken = skuToken;
- }
- else {
- MGLAccountManager.sharedManager.skuTokenExpiration = [NSDate distantFuture];
- MGLAccountManager.sharedManager.skuToken = nil;
- }
+ NSTimeInterval oneHour = 60 * 60; // TODO: make this const
+ MGLAccountManager.sharedManager.skuTokenExpiration = [NSDate dateWithTimeIntervalSinceNow:oneHour];
+
+ MGLAccountManager.sharedManager.skuToken = skuToken;
}
+ (NSString *)skuToken {
- if (MGLAccountManager.isAccountsSDKEnabled) {
- return [MGLAccountManager.sharedManager isSKUTokenExpired] ?
- MBXSKUToken.mapsToken :
- MGLAccountManager.sharedManager.skuToken;
- }
- else {
- return nil;
- }
+ return [MGLAccountManager.sharedManager isSKUTokenExpired] ? [MBXSKUToken skuToken] : MGLAccountManager.sharedManager.skuToken;
}
- (BOOL)isSKUTokenExpired {
diff --git a/platform/darwin/src/MGLAccountManager_Private.h b/platform/darwin/src/MGLAccountManager_Private.h
index 366e3097f3..3fd45f1ae8 100644
--- a/platform/darwin/src/MGLAccountManager_Private.h
+++ b/platform/darwin/src/MGLAccountManager_Private.h
@@ -15,8 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
/// The current global SKU.
-@property (class, atomic, readonly, nullable) NSString *skuToken;
-@property (class, nonatomic, readonly) BOOL isAccountsSDKEnabled;
+@property (class, atomic, readonly) NSString *skuToken;
#endif
@end
diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm
index c4b18ffd3c..29f8f7db68 100644
--- a/platform/darwin/src/http_file_source.mm
+++ b/platform/darwin/src/http_file_source.mm
@@ -208,17 +208,10 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource,
if (impl->accountType == 0 &&
([url.host isEqualToString:@"mapbox.com"] || [url.host hasSuffix:@".mapbox.com"])) {
NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
-
- NSMutableArray *newQueryItems = [NSMutableArray arrayWithArray:@[
- [NSURLQueryItem queryItemWithName:@"events" value:@"true"]
- ]];
-
- // Only add the token if we have enabled the accounts SDK
- if (MGLAccountManager.isAccountsSDKEnabled)
- {
- NSCAssert(MGLAccountManager.skuToken, @"skuToken should be non-nil if the accounts SDK is enabled");
- [newQueryItems addObject:[NSURLQueryItem queryItemWithName:@"sku" value:MGLAccountManager.skuToken]];
- }
+ NSArray *newQueryItems = @[
+ [NSURLQueryItem queryItemWithName:@"events" value:@"true"],
+ [NSURLQueryItem queryItemWithName:@"sku" value:MGLAccountManager.skuToken]
+ ];
components.queryItems = components.queryItems ? [components.queryItems arrayByAddingObjectsFromArray:newQueryItems] : newQueryItems;
diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m
index bb16f77f98..5cbb178c2c 100644
--- a/platform/ios/src/MGLMapboxEvents.m
+++ b/platform/ios/src/MGLMapboxEvents.m
@@ -1,7 +1,6 @@
#import "MGLMapboxEvents.h"
#import "MBXSKUToken.h"
#import "NSBundle+MGLAdditions.h"
-#import "MGLAccountManager_Private.h"
static NSString * const MGLAPIClientUserAgentBase = @"mapbox-maps-ios";
static NSString * const MGLMapboxAccountType = @"MGLMapboxAccountType";
@@ -145,9 +144,7 @@ static NSString * const MGLVariableGeofence = @"VariableGeofence";
[[MGLMapboxEvents sharedInstance] eventsManager].baseURL = [MGLMapboxEvents sharedInstance].baseURL;
}
- if (MGLAccountManager.isAccountsSDKEnabled) {
- [[self sharedInstance] eventsManager].skuId = MBXAccountsMapsSKUIDMaps;
- }
+ [[MGLMapboxEvents sharedInstance] eventsManager].skuId = MBXAccountsSKUIDMaps;
[self flush];
});
diff --git a/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h b/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h
index e83ffd2288..3a812c89ad 100644
--- a/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h
+++ b/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h
@@ -2,13 +2,11 @@
NS_ASSUME_NONNULL_BEGIN
-extern NSString *const MBXAccountsMapsSKUIDMaps;
-extern NSString *const MBXAccountsNavigationSKUIDMaps;
+extern NSString *const MBXAccountsSKUIDMaps;
@interface MBXSKUToken : NSObject
-@property (class, nonatomic, readonly) NSString *mapsToken;
-@property (class, nonatomic, readonly) NSString *navigationToken;
++ (NSString *)skuToken;
@end
diff --git a/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a b/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a
index 678265bf35..e18e8ef4ef 100644
--- a/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a
+++ b/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a
Binary files differ