Skip to content

Commit ca49c33

Browse files
fix: add Storyboard support
Related to devgeeks#62
1 parent 8471ceb commit ca49c33

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-privacyscreen",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.",
55
"cordova": {
66
"id": "cordova-plugin-privacyscreen",

src/ios/PrivacyScreenPlugin.m

+22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ - (void)onAppWillResignActive:(UIApplication *)application
3838
} else {
3939
imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
4040
[imageView setImage:splash];
41+
42+
if ([self isUsingCDVLaunchScreen]) {
43+
// launch screen expects the image to be scaled using AspectFill.
44+
imageView.contentMode = UIViewContentModeScaleAspectFill;
45+
}
4146

4247
#ifdef __CORDOVA_4_0_0
4348
[[UIApplication sharedApplication].keyWindow addSubview:imageView];
@@ -47,6 +52,17 @@ - (void)onAppWillResignActive:(UIApplication *)application
4752
}
4853
}
4954

55+
- (BOOL) isUsingCDVLaunchScreen
56+
{
57+
NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
58+
59+
if (launchStoryboardName) {
60+
return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]);
61+
}
62+
63+
return NO;
64+
}
65+
5066
// Code below borrowed from the CDV splashscreen plugin @ https://github.com/apache/cordova-plugin-splashscreen
5167
// Made some adjustments though, becuase landscape splashscreens are not available for iphone < 6 plus
5268
- (CDV_iOSDevice) getCurrentDevice
@@ -83,6 +99,12 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
8399

84100
NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
85101

102+
// detect if we are using CB-9762 Launch Storyboard; if so, return the associated image instead
103+
if ([self isUsingCDVLaunchScreen]) {
104+
imageName = @"LaunchStoryboard";
105+
return imageName;
106+
}
107+
86108
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
87109
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
88110
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);

0 commit comments

Comments
 (0)