summaryrefslogtreecommitdiff
path: root/ios/app/MBXAppDelegate.m
diff options
context:
space:
mode:
Diffstat (limited to 'ios/app/MBXAppDelegate.m')
-rw-r--r--ios/app/MBXAppDelegate.m16
1 files changed, 16 insertions, 0 deletions
diff --git a/ios/app/MBXAppDelegate.m b/ios/app/MBXAppDelegate.m
index f2ef69ec63..4d314483ae 100644
--- a/ios/app/MBXAppDelegate.m
+++ b/ios/app/MBXAppDelegate.m
@@ -1,11 +1,27 @@
#import "MBXAppDelegate.h"
#import "MBXViewController.h"
+#import <mbgl/ios/MapboxGL.h>
#import <mbgl/ios/MGLMapboxEvents.h>
@implementation MBXAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
+ // Set Access Token
+ 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.");
+
+ [MapboxGL sharedInstanceWithAccessToken:accessToken];
+
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[MBXViewController new]];
[self.window makeKeyAndVisible];