aboutsummaryrefslogtreecommitdiff
path: root/ios/Frontend/AppDelegate.m
diff options
context:
space:
mode:
authorHusam Salhab <47015061+hsalhab@users.noreply.github.com>2020-06-24 20:01:35 -0400
committerGitHub <noreply@github.com>2020-06-24 20:01:35 -0400
commitc301252081ef31fe24160713d801722fc73e703b (patch)
tree86f4d47d56a3945ab8f763e132b81aaaa5b2e2f8 /ios/Frontend/AppDelegate.m
parent4efe926122873adf8a598bb18b3eaf5d5a077cb4 (diff)
parentd9e0cde89b1e2c2483f91c656d6000f3b806181d (diff)
Merge pull request #3 from leonyjiang/master
[TMA-55] - Add react-native/typescript template
Diffstat (limited to 'ios/Frontend/AppDelegate.m')
-rw-r--r--ios/Frontend/AppDelegate.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/ios/Frontend/AppDelegate.m b/ios/Frontend/AppDelegate.m
new file mode 100644
index 00000000..0b7cba69
--- /dev/null
+++ b/ios/Frontend/AppDelegate.m
@@ -0,0 +1,58 @@
+#import "AppDelegate.h"
+
+#import <React/RCTBridge.h>
+#import <React/RCTBundleURLProvider.h>
+#import <React/RCTRootView.h>
+
+#if DEBUG
+#import <FlipperKit/FlipperClient.h>
+#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
+#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
+#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
+#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
+#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
+
+static void InitializeFlipper(UIApplication *application) {
+ FlipperClient *client = [FlipperClient sharedClient];
+ SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
+ [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
+ [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
+ [client addPlugin:[FlipperKitReactPlugin new]];
+ [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
+ [client start];
+}
+#endif
+
+@implementation AppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+#if DEBUG
+ InitializeFlipper(application);
+#endif
+
+ RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
+ moduleName:@"Frontend"
+ initialProperties:nil];
+
+ rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
+
+ self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
+ UIViewController *rootViewController = [UIViewController new];
+ rootViewController.view = rootView;
+ self.window.rootViewController = rootViewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
+{
+#if DEBUG
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
+#else
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+#endif
+}
+
+@end