diff --git a/VoidLink/AppDelegate.h b/VoidLink/AppDelegate.h index 4604f3bf..779b275d 100644 --- a/VoidLink/AppDelegate.h +++ b/VoidLink/AppDelegate.h @@ -10,6 +10,7 @@ @interface AppDelegate : UIResponder +@property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) NSString *pcUuidToLoad; @property (strong, nonatomic) void (^shortcutCompletionHandler)(BOOL); diff --git a/VoidLink/AppDelegate.m b/VoidLink/AppDelegate.m index 22f0179e..e1a163ff 100644 --- a/VoidLink/AppDelegate.m +++ b/VoidLink/AppDelegate.m @@ -60,6 +60,27 @@ static NSString* DB_NAME = @"Limelight_iOS.sqlite"; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for command tool customization after application launch (works only when user default is nil) [CommandManager presetDefaultCommands]; + + // For iOS 12 and below, we need to manually create the window + if (@available(iOS 13.0, *)) { + // Scene delegate will handle window creation + } else { + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + + NSString *storyboardName; + if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) { + storyboardName = @"iPad"; + } else { + storyboardName = @"iPhone"; + } + + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; + UIViewController *initialViewController = [storyboard instantiateInitialViewController]; + + self.window.rootViewController = initialViewController; + [self.window makeKeyAndVisible]; + } + return YES; } diff --git a/VoidLink/SceneDelegate.h b/VoidLink/SceneDelegate.h index 3a908f88..6763caa0 100644 --- a/VoidLink/SceneDelegate.h +++ b/VoidLink/SceneDelegate.h @@ -1,5 +1,6 @@ #import +API_AVAILABLE(ios(13.0)) @interface SceneDelegate : UIResponder @property (strong, nonatomic) UIWindow * window; diff --git a/VoidLink/SceneDelegate.m b/VoidLink/SceneDelegate.m index 58344cfd..275aaedc 100644 --- a/VoidLink/SceneDelegate.m +++ b/VoidLink/SceneDelegate.m @@ -1,6 +1,7 @@ #import "SceneDelegate.h" #import "StreamFrameViewController.h" +API_AVAILABLE(ios(13.0)) @implementation SceneDelegate static UIView *_sharedStreamVideoRenderView = nil; diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index 57373ac3..df926aec 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -810,7 +810,9 @@ - (void) returnToMainFrame { // Reset display mode back to default [self updatePreferredDisplayMode:NO]; - [SceneDelegate clearExternalDisplayRenderView]; + if (@available(iOS 13.0, *)) { + [SceneDelegate clearExternalDisplayRenderView]; + } if (_settings.enablePIP) { [self cleanupPiPController]; @@ -834,7 +836,9 @@ if (_streamVideoRenderView) { // Remove from current superview before passing it [_streamVideoRenderView removeFromSuperview]; - [SceneDelegate setExternalDisplayRenderView:_streamVideoRenderView]; + if (@available(iOS 13.0, *)) { + [SceneDelegate setExternalDisplayRenderView:_streamVideoRenderView]; + } NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName:@"ScreenChanged" object:self]; } else { @@ -847,7 +851,9 @@ - (void)extScreenDidDisconnect:(NSNotification *)notification { Log(LOG_I, @"External Screen Disconnected"); if(UIScreen.screens.count < 2) { - [SceneDelegate clearExternalDisplayRenderView]; + if (@available(iOS 13.0, *)) { + [SceneDelegate clearExternalDisplayRenderView]; + } // Add the render view back to the local StreamView if AirPlay was active if ([self isAirPlayEnabled]) { if (_streamVideoRenderView && _streamView) { @@ -878,9 +884,13 @@ - (void) reloadAirPlayConfig{ if (UIScreen.screens.count == 1){return;} if (![self isAirPlaying] && [self isAirPlayEnabled]){ - [SceneDelegate setExternalDisplayRenderView:_streamVideoRenderView]; + if (@available(iOS 13.0, *)) { + [SceneDelegate setExternalDisplayRenderView:_streamVideoRenderView]; + } }else if ([self isAirPlaying] && ![self isAirPlayEnabled]){ - [SceneDelegate clearExternalDisplayRenderView]; + if (@available(iOS 13.0, *)) { + [SceneDelegate clearExternalDisplayRenderView]; + } } }