77#import " AppDelegate+privacyscreen.h"
88#import < objc/runtime.h>
99
10+ UIImageView *imageView;
11+
1012@implementation AppDelegate (privacyscreen)
1113
1214// Taken from https://github.com/phonegap-build/PushPlugin/blob/master/src/ios/AppDelegate%2Bnotification.m
@@ -33,14 +35,38 @@ - (AppDelegate *)swizzled_init
3335
3436- (void )applicationDidBecomeActive : (UIApplication *)application
3537{
36- [[UIApplication sharedApplication ] ignoreSnapshotOnNextApplicationLaunch ];
37- self.window .hidden = NO ;
38+ if (imageView == NULL ) {
39+ [[UIApplication sharedApplication ] ignoreSnapshotOnNextApplicationLaunch ];
40+ self.window .hidden = NO ;
41+ } else {
42+ [imageView removeFromSuperview ];
43+ }
3844}
3945
4046- (void )applicationWillResignActive : (UIApplication *)application
4147{
42- [[UIApplication sharedApplication ] ignoreSnapshotOnNextApplicationLaunch ];
43- self.window .hidden = YES ;
48+ // for now, assuming 'Default' is the basename of the splashscreen, with a fallback to hiding the window
49+ UIImage *splash = [self imageNamedForDevice: @" Default" ];
50+ if (splash == NULL ) {
51+ [[UIApplication sharedApplication ] ignoreSnapshotOnNextApplicationLaunch ];
52+ self.window .hidden = YES ;
53+ } else {
54+ imageView = [[UIImageView alloc ]initWithFrame:[self .window frame ]];
55+ [imageView setImage: splash];
56+ [UIApplication.sharedApplication.keyWindow.subviews.lastObject addSubview: imageView];
57+ }
58+ }
59+
60+ - (UIImage*)imageNamedForDevice : (NSString *)name
61+ {
62+ if (UI_USER_INTERFACE_IDIOM () == UIUserInterfaceIdiomPhone) {
63+ if (([UIScreen mainScreen ].bounds .size .height * [UIScreen mainScreen ].scale ) >= 1136 .0f ) {
64+ name = [name stringByAppendingString: @" -568h@2x" ];
65+ }
66+ } else if (UI_USER_INTERFACE_IDIOM () == UIUserInterfaceIdiomPad) {
67+ name = [name stringByAppendingString: @" -Portrait" ];
68+ }
69+ return [UIImage imageNamed: name];
4470}
4571
4672@end
0 commit comments