summaryrefslogtreecommitdiff
path: root/ios/app
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-04-23 18:15:01 -0500
committerBrad Leege <bleege@gmail.com>2015-04-23 18:15:01 -0500
commit7e145780ebbd5d35a74f263c51827ae2a37c4eb8 (patch)
tree65b802c19ce520c2c0b1a1c99ab976ba84cbb23b /ios/app
parent19b5ef367ead43c9e156807ed86da065b0fd3ba2 (diff)
downloadqtlocation-mapboxgl-7e145780ebbd5d35a74f263c51827ae2a37c4eb8.tar.gz
#1225 - Initial conversion of Mapbox GL app to set access token in AppDelegate and exposing MGLMapView.initWithFrame to support it
Diffstat (limited to 'ios/app')
-rw-r--r--ios/app/MBXAppDelegate.m16
-rw-r--r--ios/app/MBXViewController.mm15
2 files changed, 17 insertions, 14 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];
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index 13235beb07..394536b98b 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -52,20 +52,7 @@ mbgl::Settings_NSUserDefaults *settings = nullptr;
{
[super viewDidLoad];
- 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.");
-
- self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds accessToken:accessToken];
+ self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.viewControllerForLayoutGuides = self;
self.mapView.showsUserLocation = YES;