IOS 8: remove sensitive information from views before going to the background

In iOS 7, my application introduced an authentication screen when the application went into the background (by subscribing to UIApplicationDidEnterBackgroundNotification ). The authentication controller deleted sensitive information so that user information is not displayed on the screen capture. On iOS 8, this no longer works. The screenshot now shows the view in which the last user worked, and not the authentication controller ... even if the application returns to the forefront, the authentication controller is active.

At the moment, I have found a job. Instead of using UIApplicationDidEnterBackgroundNotification I can use name:UIApplicationWillResignActiveNotification , however this causes a flash to appear when the user leaves the application.

Whether this is a mistake or an apple provides a new way to remove important information from views before moving to the background.

Note. Put ignoreSnapshotOnNextApplicationLaunch in applicationWillResignActive: and applicationDidEnterBackground: did not help.

Update: error report generated

+5
source share
2 answers

A similar approach to @ Gurudev0777, but instead uses UIBlurEffect to hide content, and has no shortage of worrying about different device screen metrics. Application Delegate:

 #define MY_BACKGROUND_SCREEN_TAG 1001//or any random but UNIQUE number. - (void)applicationDidEnterBackground:(UIApplication *)application { // Visual effect view for blur UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; [blurView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; [blurView setFrame:self.window.frame]; blurView.tag = MY_BACKGROUND_SCREEN_TAG; [self.window addSubview:blurView]; } - (void)applicationWillEnterForeground:(UIApplication *)application { // remove blur view if present UIView *view = [self.window viewWithTag:MY_BACKGROUND_SCREEN_TAG]; if (view != nil) { [UIView animateWithDuration:0.2f animations:^{ [view setAlpha:0]; } completion:^(BOOL finished) { [view removeFromSuperview]; }]; } } 

works like a charm ...

Edited 5/18/2015 : Thanks @Simeon Rice for watching modal dialogs, revised to add blur to self.window instead of rootViewController.view

Edited 8/23/2016 : Thanks @tpankake for watching re: autoscaling mask.

+4
source
 here we are putting an imageview while the app animate to background - -(void)applicationWillResignActive:(UIApplication *)application { imageView = [[UIImageView alloc]initWithFrame:[self.window frame]]; [imageView setImage:[UIImage imageNamed:@" Default@2x.png "]]; [self.window addSubview:imageView]; } Here is the code to remove the imageview: - (void)applicationDidBecomeActive:(UIApplication *)application { if(imageView != nil) { [imageView removeFromSuperview]; imageView = nil; } } It is working and tested many times. *** Please test this scenario into the device not in simulator. 
-1
source

Source: https://habr.com/ru/post/1202365/


All Articles