diff options
Diffstat (limited to 'platform/ios/Integration Test Harness/AppDelegate.m')
-rw-r--r-- | platform/ios/Integration Test Harness/AppDelegate.m | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/platform/ios/Integration Test Harness/AppDelegate.m b/platform/ios/Integration Test Harness/AppDelegate.m index 4483c5f98a..ae15af62d2 100644 --- a/platform/ios/Integration Test Harness/AppDelegate.m +++ b/platform/ios/Integration Test Harness/AppDelegate.m @@ -1,5 +1,9 @@ +#import "Mapbox.h" + #import "AppDelegate.h" +NSString * const MBXMapboxAccessTokenDefaultsKey = @"MBXMapboxAccessToken"; + @interface AppDelegate () @end @@ -8,6 +12,20 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Set access token, unless MGLAccountManager already read it in from Info.plist. + if ( ! [MGLAccountManager accessToken]) { + NSString *accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"]; + if (accessToken) { + // Store to preferences so that we can launch the app later on without having to specify + // token. + [[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:MBXMapboxAccessTokenDefaultsKey]; + } else { + // Try to retrieve from preferences, maybe we've stored them there previously and can reuse + // the token. + accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:MBXMapboxAccessTokenDefaultsKey]; + } + [MGLAccountManager setAccessToken:accessToken]; + } return YES; } |