diff options
Diffstat (limited to 'platform/ios/benchmark/MBXBenchAppDelegate.m')
-rw-r--r-- | platform/ios/benchmark/MBXBenchAppDelegate.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/platform/ios/benchmark/MBXBenchAppDelegate.m b/platform/ios/benchmark/MBXBenchAppDelegate.m new file mode 100644 index 0000000000..5da6ccfcec --- /dev/null +++ b/platform/ios/benchmark/MBXBenchAppDelegate.m @@ -0,0 +1,32 @@ +#import "MBXBenchAppDelegate.h" +#import "MBXBenchViewController.h" +#import <Mapbox/Mapbox.h> + +@implementation MBXBenchAppDelegate + +- (BOOL)application:(UIApplication*)application + didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { + 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:@"access_token"]; + } else { + // Try to retrieve from preferences, maybe we've stored them there previously and can reuse + // the token. + accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"access_token"]; + } + if (!accessToken) { + NSLog(@"No access token set. Mapbox vector tiles won't work."); + } else { + [MGLAccountManager setAccessToken:accessToken]; + } + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.rootViewController = [MBXBenchViewController new]; + [self.window makeKeyAndVisible]; + + return YES; +} + +@end |