20@synthesize sceneLifeCycleDelegate = _sceneLifeCycleDelegate;
23 if (
self = [super init]) {
29#pragma mark - Connecting and disconnecting the scene
31- (void)scene:(UIScene*)scene
32 willConnectToSession:(UISceneSession*)session
33 options:(UISceneConnectionOptions*)connectionOptions {
35 if ([appDelegate respondsToSelector:@selector(
window)] && appDelegate.
window.rootViewController) {
36 NSLog(
@"WARNING - The UIApplicationDelegate is setting up the UIWindow and "
37 @"UIWindow.rootViewController at launch. This was deprecated after the "
38 @"UISceneDelegate adoption. Setup logic should be moved to a UISceneDelegate.");
41 UIWindowScene* windowScene = (UIWindowScene*)scene;
42 [
self moveRootViewControllerFrom:appDelegate to:windowScene];
44 [
self.sceneLifeCycleDelegate scene:scene willConnectToSession:session options:connectionOptions];
47- (void)sceneDidDisconnect:(UIScene*)scene {
48 [
self.sceneLifeCycleDelegate sceneDidDisconnect:scene];
51#pragma mark - Transitioning to the foreground
53- (void)sceneWillEnterForeground:(UIScene*)scene {
54 [
self.sceneLifeCycleDelegate sceneWillEnterForeground:scene];
57- (void)sceneDidBecomeActive:(UIScene*)scene {
58 [
self.sceneLifeCycleDelegate sceneDidBecomeActive:scene];
61#pragma mark - Transitioning to the background
63- (void)sceneWillResignActive:(UIScene*)scene {
64 [
self.sceneLifeCycleDelegate sceneWillResignActive:scene];
67- (void)sceneDidEnterBackground:(UIScene*)scene {
68 [
self.sceneLifeCycleDelegate sceneDidEnterBackground:scene];
71#pragma mark - Opening URLs
73- (void)scene:(UIScene*)scene openURLContexts:(NSSet<UIOpenURLContext*>*)URLContexts {
74 [
self.sceneLifeCycleDelegate scene:scene openURLContexts:URLContexts];
77#pragma mark - Continuing user activities
79- (void)scene:(UIScene*)scene continueUserActivity:(NSUserActivity*)userActivity {
80 [
self.sceneLifeCycleDelegate scene:scene continueUserActivity:userActivity];
83#pragma mark - Saving the state of the scene
85- (NSUserActivity*)stateRestorationActivityForScene:(UIScene*)scene {
86 return [
self.sceneLifeCycleDelegate stateRestorationActivityForScene:scene];
89- (void)scene:(UIScene*)scene
90 restoreInteractionStateWithUserActivity:(NSUserActivity*)stateRestorationActivity {
91 [
self.sceneLifeCycleDelegate scene:scene
92 restoreInteractionStateWithUserActivity:stateRestorationActivity];
95#pragma mark - Performing tasks
97- (void)windowScene:(UIWindowScene*)windowScene
98 performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
99 completionHandler:(
void (^)(
BOOL succeeded))completionHandler {
100 [
self.sceneLifeCycleDelegate windowScene:windowScene
101 performActionForShortcutItem:shortcutItem
102 completionHandler:completionHandler];
105#pragma mark - Helpers
108 return [
self.sceneLifeCycleDelegate registerSceneLifeCycleWithFlutterEngine:engine];
112 return [
self.sceneLifeCycleDelegate unregisterSceneLifeCycleWithFlutterEngine:engine];
115- (void)moveRootViewControllerFrom:(NSObject<UIApplicationDelegate>*)appDelegate
116 to:(UIWindowScene*)windowScene {
117 self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
118 self.window.rootViewController = appDelegate.window.rootViewController;
119 appDelegate.window =
self.window;
120 [
self.window makeKeyAndVisible];
FlutterSceneLifeCycleEngineRegistration UIWindow * window
UIApplication * application