react-native-webview.git

AppDelegate.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import "AppDelegate.h"
  8. #import <React/RCTBridge.h>
  9. #import <React/RCTBundleURLProvider.h>
  10. #import <React/RCTDevMenu.h>
  11. #import <React/RCTRootView.h>
  12. @implementation AppDelegate {
  13. __weak RCTBridge *_bridge;
  14. }
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  16. {
  17. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  18. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
  19. moduleName:@"RNCWebViewExample"
  20. initialProperties:nil];
  21. rootView.backgroundColor = [UIColor blackColor];
  22. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  23. UIViewController *rootViewController = [UIViewController new];
  24. rootViewController.view = rootView;
  25. self.window.rootViewController = rootViewController;
  26. [self.window makeKeyAndVisible];
  27. return YES;
  28. }
  29. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  30. {
  31. #if DEBUG
  32. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"example/index" fallbackResource:nil];
  33. #else
  34. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  35. #endif
  36. }
  37. @end