diff options
Diffstat (limited to 'platform/ios/app/MBXAppDelegate.m')
-rw-r--r-- | platform/ios/app/MBXAppDelegate.m | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/platform/ios/app/MBXAppDelegate.m b/platform/ios/app/MBXAppDelegate.m new file mode 100644 index 0000000000..a06424feb7 --- /dev/null +++ b/platform/ios/app/MBXAppDelegate.m @@ -0,0 +1,33 @@ +#import "MBXAppDelegate.h" +#import "MBXViewController.h" +#import <Mapbox/Mapbox.h> + +@implementation MBXAppDelegate + +- (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:@"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."); + + [MGLAccountManager setAccessToken:accessToken]; + } + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[MBXViewController new]]; + [self.window makeKeyAndVisible]; + + return YES; +} + +@end |