Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ __attribute__((deprecated(

- (RCTRootViewFactory *)rootViewFactory;

- (UISceneConfiguration *)application:(UIApplication *)application
configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession
options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0));

@end

NS_ASSUME_NONNULL_END
10 changes: 10 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ - (void)setBridgeAdapter:(RCTSurfacePresenterBridgeAdapter *)bridgeAdapter
self.reactNativeFactory.rootViewFactory.bridgeAdapter = bridgeAdapter;
}

- (UISceneConfiguration *)application:(UIApplication *)application
configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession
options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0))
{
UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:@"Default Configuration"
sessionRole:connectingSceneSession.role];
configuration.delegateClass = NSClassFromString(@"RCTSceneDelegate");
return configuration;
}

@end
21 changes: 21 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTSceneDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <UIKit/UIKit.h>

@class RCTReactNativeFactory;

NS_ASSUME_NONNULL_BEGIN

API_AVAILABLE(ios(13.0))
@interface RCTSceneDelegate : UIResponder <UIWindowSceneDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

NS_ASSUME_NONNULL_END
70 changes: 70 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTSceneDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "RCTSceneDelegate.h"
#import <UIKit/UIKit.h>
#import "RCTAppDelegate.h"
#import "RCTReactNativeFactory.h"
#import "RCTRootViewFactory.h"

@implementation RCTSceneDelegate

- (void)scene:(UIScene *)scene
willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0))
{
if (![scene isKindOfClass:[UIWindowScene class]]) {
return;
}

UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];

// Get the app delegate to access the React Native factory
RCTAppDelegate *appDelegate = (RCTAppDelegate *)[UIApplication sharedApplication].delegate;

if (appDelegate && [appDelegate respondsToSelector:@selector(rootViewFactory)]) {
RCTRootViewFactory *rootViewFactory = appDelegate.rootViewFactory;

UIView *rootView = [rootViewFactory viewWithModuleName:appDelegate.moduleName
initialProperties:appDelegate.initialProps
launchOptions:nil];

UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
}

[self.window makeKeyAndVisible];
}

- (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0))
{
// Scene disconnected
}

- (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0))
{
// Scene became active
}

- (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0))
{
// Scene will resign active
}

- (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0))
{
// Scene will enter foreground
}

- (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0))
{
// Scene entered background
}

@end
17 changes: 17 additions & 0 deletions packages/rn-tester/RNTester/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,22 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>RCTSceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
Loading