From bfc87a6517f0b70b82ea760b8d052381bddf1ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Fri, 12 Jan 2024 11:21:17 +0100 Subject: [PATCH] feat(ios): support multi-scene applications (#13941) * feat: support multi-scene applications * fix: add keys to template Info.plist to restore backwards compatibility --- .../TitaniumKit/Sources/API/TiApp.h | 9 +------ .../TitaniumKit/Sources/API/TiApp.m | 27 +++++++++++-------- iphone/iphone/Titanium.plist | 17 ++++++++++++ support/iphone/Info.plist | 17 ++++++++++++ 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h index 85053a484da..a9fe584766f 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h @@ -13,17 +13,10 @@ #import "TiRootViewController.h" #import -extern BOOL applicationInMemoryPanic; // TODO: Remove in SDK 9.0+ - -// TODO: Remove in SDK 9.0+ -TI_INLINE void waitForMemoryPanicCleared() //WARNING: This must never be run on main thread, or else there is a risk of deadlock! -{ -} - /** TiApp represents an instance of an application. There is always only one instance per application which could be accessed through class method. */ -@interface TiApp : TiHost { +@interface TiApp : TiHost { UIWindow *window; UIImageView *loadView; UIView *splashScreenView; diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m index fd53a04cc7f..310aefd339d 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m @@ -33,11 +33,6 @@ #define SHUTDOWN_TIMEOUT_IN_SEC 3 -BOOL applicationInMemoryPanic = NO; // TODO: Remove in SDK 9.0+ - -// TODO: Remove in SDK 9.0+ -TI_INLINE void waitForMemoryPanicCleared(void); //WARNING: This must never be run on main thread, or else there is a risk of deadlock! - @interface TiApp () - (void)checkBackgroundServices; - (void)appBoot; @@ -327,15 +322,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [[TiLogServer defaultLogServer] start]; } - // Initialize the root-window - window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - // Initialize the launch options to be used by the client launchOptions = [[NSMutableDictionary alloc] initWithDictionary:launchOptions_]; - // Initialize the root-controller - [self initController]; - // If we have a APNS-UUID, assign it NSString *apnsUUID = [[NSUserDefaults standardUserDefaults] stringForKey:@"APNSRemoteDeviceUUID"]; if (apnsUUID != nil) { @@ -1235,6 +1224,22 @@ - (KrollBridge *)krollBridge return kjsBridge; } +#pragma mark UIWindowSceneDelegate + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options +{ + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions +{ + // Initialize the root-window + window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene]; + + // Initialize the root-controller + [self initController]; +} + #pragma mark Background Tasks - (void)beginBackgrounding diff --git a/iphone/iphone/Titanium.plist b/iphone/iphone/Titanium.plist index 997d287518d..448f4c87fe8 100644 --- a/iphone/iphone/Titanium.plist +++ b/iphone/iphone/Titanium.plist @@ -78,5 +78,22 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + TiApp + + + + diff --git a/support/iphone/Info.plist b/support/iphone/Info.plist index f9500da5954..72b06667636 100644 --- a/support/iphone/Info.plist +++ b/support/iphone/Info.plist @@ -36,5 +36,22 @@ 1.0 LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + TiApp + + + +