diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m index a2dc755..bd573d0 100644 --- a/src/ios/PrivacyScreenPlugin.m +++ b/src/ios/PrivacyScreenPlugin.m @@ -40,7 +40,12 @@ - (void)onAppWillResignActive:(UIApplication *)application imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]]; imageView.contentMode = UIViewContentModeScaleAspectFill; [imageView setImage:splash]; - + + if ([self isUsingCDVLaunchScreen]) { + // launch screen expects the image to be scaled using AspectFill. + imageView.contentMode = UIViewContentModeScaleAspectFill; + } + #ifdef __CORDOVA_4_0_0 [[UIApplication sharedApplication].keyWindow addSubview:imageView]; #else @@ -75,13 +80,27 @@ - (CDV_iOSDevice) getCurrentDevice return device; } +- (BOOL) isUsingCDVLaunchScreen { + NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"]; + if (launchStoryboardName) { + return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]); + } else { + return NO; + } +} + - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id)orientationDelegate device:(CDV_iOSDevice)device { // Use UILaunchImageFile if specified in plist. Otherwise, use Default. NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"]; NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations]; - + + // Detect if we are using Launch Storyboard and return the associated image instead + if ([self isUsingCDVLaunchScreen]) { + imageName = @"LaunchStoryboard"; + return imageName; + } // Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape); BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);