Files
MapLibreParticleLab/platform/ios/app/MBXAppDelegate.m
Fabian Guerra Soto c8fbcfd322 [ios, macos] Logging. (#13235)
* [ios, macos] Update the logging subsystem to platform agnostic.

* [ios, macos] Add coordinate to string function.

* [ios, macos] Add BOOL to string function.

* [ios, macos] Add tracing logs.

* [ios, macos] Add tracing logs to generated style classes.

* [ios, macos] Split logging categories accordingly to MGLLoggingLevel.

* [ios, macos] Log network requests.

* [ios, macos] Migrate NSAssert to MGLAssert.

* [ios, macos] Include MGLLoggingConfiguration to filesource-files.txt.

* [ios, macos] Fix logger string specifier for the line parameter.

* [ios, macos] Add logs to shapes classes.

* [ios, macos] Add logs to offline classes.

* [ios, macos] Add logs to annotation classes.

* [ios, macos] Add logs to foundation classes.

* [ios, macos] Fix snapshotter size logging.

* [macos] Add logs to map view.

* [ios, macos] Fix string from boolean prefix, add custom function for NSCAssert.

* Log size test

* [ios, macos] Add logging conditional compilation flag.

* [ios, macos] Rename function NSStringFromMGLTransition to MGLStringFromMGLTransition.

* [ios, macos] Remove verbose logging for release builds.

* [ios, macos] Rename NSStringFromCLLocationCoordinate2D to MGLStringFromCLLocationCoordinate2D.

* [ios, macos] Clean unnecesary blank lines in MGLLight.mm set methods.

* [ios, macos] Fix logging grammar, format, function names.

* [ios, macos] Remove compilation flag, rename flags.
2018-11-14 15:42:18 -08:00

51 lines
1.9 KiB
Objective-C

#import "MBXAppDelegate.h"
#import "MBXViewController.h"
#import <Mapbox/Mapbox.h>
NSString * const MBXMapboxAccessTokenDefaultsKey = @"MBXMapboxAccessToken";
@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: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];
#ifndef MGL_DISABLE_LOGGING
[MGLLoggingConfiguration sharedConfiguration].loggingLevel = MGLLoggingLevelFault;
#endif
}
return YES;
}
#pragma mark - Quick actions
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
completionHandler([self handleShortcut:shortcutItem]);
}
- (BOOL)handleShortcut:(UIApplicationShortcutItem *)shortcut {
if ([[shortcut.type componentsSeparatedByString:@"."].lastObject isEqual:@"settings"]) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
});
return YES;
}
return NO;
}
@end