2016-02-18 19:59:34 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright 2016 Realm Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2015-10-02 21:57:54 +00:00
|
|
|
|
|
|
|
#import "AppDelegate.h"
|
2017-01-10 13:00:23 +00:00
|
|
|
|
|
|
|
#import <React/RCTBundleURLProvider.h>
|
|
|
|
#import <React/RCTRootView.h>
|
2015-10-02 21:57:54 +00:00
|
|
|
|
2015-10-26 20:25:15 +00:00
|
|
|
static NSString * const RealmReactEnableChromeDebuggingKey = @"RealmReactEnableChromeDebugging";
|
|
|
|
static NSString * const RCTDevMenuKey = @"RCTDevMenu";
|
|
|
|
|
2015-10-02 21:57:54 +00:00
|
|
|
@implementation AppDelegate
|
|
|
|
|
2015-10-26 20:25:15 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
// Check if this default is explicitly set, otherwise just leave the settings as is.
|
|
|
|
if ([defaults objectForKey:RealmReactEnableChromeDebuggingKey]) {
|
|
|
|
NSMutableDictionary *settings = [([defaults dictionaryForKey:RCTDevMenuKey] ?: @{}) mutableCopy];
|
|
|
|
NSMutableDictionary *domain = [[defaults volatileDomainForName:NSArgumentDomain] mutableCopy];
|
|
|
|
|
2016-01-06 23:24:00 +00:00
|
|
|
settings[@"executorClass"] = [defaults boolForKey:RealmReactEnableChromeDebuggingKey] ? @"RCTWebSocketExecutor" : @"RCTJSCExecutor";
|
2015-10-26 20:25:15 +00:00
|
|
|
domain[RCTDevMenuKey] = settings;
|
|
|
|
|
|
|
|
// Re-register the arguments domain (highest precedent and volatile) with our new overridden settings.
|
|
|
|
[defaults removeVolatileDomainForName:NSArgumentDomain];
|
|
|
|
[defaults setVolatileDomain:domain forName:NSArgumentDomain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2017-01-10 13:00:23 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
|
|
{
|
|
|
|
NSURL *jsCodeLocation;
|
2015-10-22 09:34:46 +00:00
|
|
|
|
2017-01-10 13:00:23 +00:00
|
|
|
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
|
2015-10-22 09:34:46 +00:00
|
|
|
|
2017-01-10 13:00:23 +00:00
|
|
|
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
|
|
|
|
moduleName:@"ReactTests"
|
|
|
|
initialProperties:nil
|
|
|
|
launchOptions:launchOptions];
|
|
|
|
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
|
2015-10-22 09:34:46 +00:00
|
|
|
|
2017-01-10 13:00:23 +00:00
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
|
UIViewController *rootViewController = [UIViewController new];
|
|
|
|
rootViewController.view = rootView;
|
|
|
|
self.window.rootViewController = rootViewController;
|
|
|
|
[self.window makeKeyAndVisible];
|
|
|
|
return YES;
|
2015-10-02 21:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|