-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
220 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/app/plugin/__tests__/fixtures/AppDelegate_bare_sdk43.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// This AppDelegate template is used in Expo SDK 43 and newer | ||
// It is (nearly) identical to the pure template used when | ||
// creating a bare React Native app (without Expo) | ||
|
||
#import "AppDelegate.h" | ||
|
||
#import <React/RCTBridge.h> | ||
#import <React/RCTBundleURLProvider.h> | ||
#import <React/RCTRootView.h> | ||
#import <React/RCTLinkingManager.h> | ||
#import <React/RCTConvert.h> | ||
|
||
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>) | ||
#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 defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>) | ||
InitializeFlipper(application); | ||
#endif | ||
|
||
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; | ||
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; | ||
id rootViewBackgroundColor = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTRootViewBackgroundColor"]; | ||
if (rootViewBackgroundColor != nil) { | ||
rootView.backgroundColor = [RCTConvert UIColor:rootViewBackgroundColor]; | ||
} else { | ||
rootView.backgroundColor = [UIColor whiteColor]; | ||
} | ||
|
||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | ||
UIViewController *rootViewController = [UIViewController new]; | ||
rootViewController.view = rootView; | ||
self.window.rootViewController = rootViewController; | ||
[self.window makeKeyAndVisible]; | ||
|
||
[super application:application didFinishLaunchingWithOptions:launchOptions]; | ||
|
||
return YES; | ||
} | ||
|
||
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge | ||
{ | ||
// If you'd like to export some custom RCTBridgeModules, add them here! | ||
return @[]; | ||
} | ||
|
||
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { | ||
#ifdef DEBUG | ||
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; | ||
#else | ||
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; | ||
#endif | ||
} | ||
|
||
// Linking API | ||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { | ||
return [RCTLinkingManager application:application openURL:url options:options]; | ||
} | ||
|
||
// Universal Links | ||
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler { | ||
return [RCTLinkingManager application:application | ||
continueUserActivity:userActivity | ||
restorationHandler:restorationHandler]; | ||
} | ||
|
||
@end |
3 changes: 3 additions & 0 deletions
3
...p/plugin/__tests__/fixtures/AppDelegate.m → ...in/__tests__/fixtures/AppDelegate_sdk42.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters