Skip to content

Commit 2853b0d

Browse files
committed
feat(ios): support multi-scene applications
1 parent d84bb4d commit 2853b0d

File tree

4 files changed

+51
-19
lines changed

4 files changed

+51
-19
lines changed

iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@
1313
#import "TiRootViewController.h"
1414
#import <JavaScriptCore/JavaScriptCore.h>
1515

16-
extern BOOL applicationInMemoryPanic; // TODO: Remove in SDK 9.0+
17-
18-
// TODO: Remove in SDK 9.0+
19-
TI_INLINE void waitForMemoryPanicCleared() // WARNING: This must never be run on main thread, or else there is a risk of deadlock!
20-
{
21-
}
22-
2316
/**
2417
TiApp represents an instance of an application. There is always only one instance per application which could be accessed through <app> class method.
2518
*/
26-
@interface TiApp : TiHost <UIApplicationDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate, UNUserNotificationCenterDelegate> {
19+
@interface TiApp : TiHost <UIApplicationDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate, UNUserNotificationCenterDelegate, UIWindowSceneDelegate> {
2720
UIWindow *window;
2821
UIImageView *loadView;
2922
UIView *splashScreenView;

iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m

+16-11
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333

3434
#define SHUTDOWN_TIMEOUT_IN_SEC 3
3535

36-
BOOL applicationInMemoryPanic = NO; // TODO: Remove in SDK 9.0+
37-
38-
// TODO: Remove in SDK 9.0+
39-
TI_INLINE void waitForMemoryPanicCleared(void); // WARNING: This must never be run on main thread, or else there is a risk of deadlock!
40-
4136
@interface TiApp ()
4237
- (void)checkBackgroundServices;
4338
- (void)appBoot;
@@ -327,15 +322,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
327322
[[TiLogServer defaultLogServer] start];
328323
}
329324

330-
// Initialize the root-window
331-
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
332-
333325
// Initialize the launch options to be used by the client
334326
launchOptions = [[NSMutableDictionary alloc] initWithDictionary:launchOptions_];
335327

336-
// Initialize the root-controller
337-
[self initController];
338-
339328
// If we have a APNS-UUID, assign it
340329
NSString *apnsUUID = [[NSUserDefaults standardUserDefaults] stringForKey:@"APNSRemoteDeviceUUID"];
341330
if (apnsUUID != nil) {
@@ -1235,6 +1224,22 @@ - (KrollBridge *)krollBridge
12351224
return kjsBridge;
12361225
}
12371226

1227+
#pragma mark UIWindowSceneDelegate
1228+
1229+
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options
1230+
{
1231+
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
1232+
}
1233+
1234+
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions
1235+
{
1236+
// Initialize the root-window
1237+
window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
1238+
1239+
// Initialize the root-controller
1240+
[self initController];
1241+
}
1242+
12381243
#pragma mark Background Tasks
12391244

12401245
- (void)beginBackgrounding

iphone/iphone/Titanium.plist

+17
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,22 @@
7474
<string>UIInterfaceOrientationLandscapeLeft</string>
7575
<string>UIInterfaceOrientationLandscapeRight</string>
7676
</array>
77+
<key>UIApplicationSceneManifest</key>
78+
<dict>
79+
<key>UIApplicationSupportsMultipleScenes</key>
80+
<true/>
81+
<key>UISceneConfigurations</key>
82+
<dict>
83+
<key>UIWindowSceneSessionRoleApplication</key>
84+
<array>
85+
<dict>
86+
<key>UISceneConfigurationName</key>
87+
<string>Default Configuration</string>
88+
<key>UISceneDelegateClassName</key>
89+
<string>TiApp</string>
90+
</dict>
91+
</array>
92+
</dict>
93+
</dict>
7794
</dict>
7895
</plist>

support/iphone/Info.plist

+17
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,22 @@
3636
<string>1.0</string>
3737
<key>LSRequiresIPhoneOS</key>
3838
<true/>
39+
<key>UIApplicationSceneManifest</key>
40+
<dict>
41+
<key>UIApplicationSupportsMultipleScenes</key>
42+
<false/>
43+
<key>UISceneConfigurations</key>
44+
<dict>
45+
<key>UIWindowSceneSessionRoleApplication</key>
46+
<array>
47+
<dict>
48+
<key>UISceneConfigurationName</key>
49+
<string>Default Configuration</string>
50+
<key>UISceneDelegateClassName</key>
51+
<string>TiApp</string>
52+
</dict>
53+
</array>
54+
</dict>
55+
</dict>
3956
</dict>
4057
</plist>

0 commit comments

Comments
 (0)