From ae42028d65a50e48c460482a51f222fb9e6940f0 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 13 May 2019 16:48:19 -0700 Subject: WIP for nav SKU changes --- platform/darwin/src/MGLAccountManager.m | 8 ++++++-- platform/ios/src/MGLMapboxEvents.m | 2 +- .../ios/vendor/mapbox-accounts-ios/MBXSKUToken.h | 22 +++++++++++++++++---- .../vendor/mapbox-accounts-ios/libmbxaccounts.a | Bin 68592 -> 77808 bytes 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/platform/darwin/src/MGLAccountManager.m b/platform/darwin/src/MGLAccountManager.m index bc3e9d236..83c9d60fb 100644 --- a/platform/darwin/src/MGLAccountManager.m +++ b/platform/darwin/src/MGLAccountManager.m @@ -42,7 +42,7 @@ static const NSTimeInterval MGLAccountManagerSKUTokenLifespan = 3600; } #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR - self.skuToken = MBXSKUToken.mapsToken; + self.skuToken = [MBXSKUToken tokenForSKUID:MBXAccountsSKUIDMaps type:MBXAccountsSKUTypeUser]; #endif } @@ -108,7 +108,11 @@ static const NSTimeInterval MGLAccountManagerSKUTokenLifespan = 3600; } + (NSString *)skuToken { - return [MGLAccountManager.sharedManager isSKUTokenExpired] ? MBXSKUToken.mapsToken : MGLAccountManager.sharedManager.skuToken; + if ([MGLAccountManager.sharedManager isSKUTokenExpired]) { + return [MBXSKUToken tokenForSKUID:MBXAccountsSKUIDMaps type:MBXAccountsSKUTypeUser]; + } else { + return MGLAccountManager.sharedManager.skuToken; + } } - (BOOL)isSKUTokenExpired { diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m index dc6391df0..d5814dab4 100644 --- a/platform/ios/src/MGLMapboxEvents.m +++ b/platform/ios/src/MGLMapboxEvents.m @@ -145,7 +145,7 @@ static NSString * const MGLVariableGeofence = @"VariableGeofence"; [[MGLMapboxEvents sharedInstance] eventsManager].baseURL = [MGLMapboxEvents sharedInstance].baseURL; } - [[self sharedInstance] eventsManager].skuId = MBXAccountsMapsSKUIDMaps; + [[self 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 e83ffd228..7dd42b47b 100644 --- a/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h +++ b/platform/ios/vendor/mapbox-accounts-ios/MBXSKUToken.h @@ -2,13 +2,27 @@ NS_ASSUME_NONNULL_BEGIN -extern NSString *const MBXAccountsMapsSKUIDMaps; -extern NSString *const MBXAccountsNavigationSKUIDMaps; +typedef NS_ENUM(NSInteger, MBXAccountsSKUID) { + MBXAccountsSKUIDMaps, + MBXAccountsSKUIDNavigation +}; + +typedef NS_ENUM(NSInteger, MBXAccountsSKUType) { + MBXAccountsSKUTypeUser, + MBXAccountsSKUTypeSession +}; @interface MBXSKUToken : NSObject -@property (class, nonatomic, readonly) NSString *mapsToken; -@property (class, nonatomic, readonly) NSString *navigationToken; +/** + Generates a token for the given identifier and type. + + @param skuId The sku identifier, e.g. maps or navigation. + @param type The type of token, e.g. user or session. + + @return A SKU token for use with API requests. + */ ++ (NSString *)tokenForSKUID:(MBXAccountsSKUID)skuId type:(MBXAccountsSKUType)type; @end diff --git a/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a b/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a index efe06835e..fe50dea10 100644 Binary files a/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a and b/platform/ios/vendor/mapbox-accounts-ios/libmbxaccounts.a differ -- cgit v1.2.3