Search code examples
iphonepasswordsscreenshotmultitasking

Preventing snapshot view of your app when coming back from multi-tasking


The problem is this - My app lets you passcode protect itself. I use an interface just like passcode protecting the phone. This has always worked fine, until multi-tasking came along.

The passcode protection still works, but there is one issue. Apple does something special to make it look like our apps are loading quicker when they come back from the background. The os takes a picture of our screen just before the user leaves the app, and it displays that while the rest of the app is still loading.

The problem this causes is that someone trying to go to my app would see that image of the screen before the passcode protection kicked in. Granted, it's not much, but I don't think my users will like the idea of people being able to get even a little glimpse of their data.

How to stop that snapshot image from showing?


Solution

  • I solved this. Here is the solution:

    - (void)applicationDidEnterBackground:(UIApplication *)application{
        if (appHasPasscodeOn){
            UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
            splashView.image = [UIImage imageNamed:@"Default.png"];
            [window addSubview:splashView];
            [splashView release];
        }
    }
    

    Default.png is a screenshot of my app with a blank screen (for me it's just a blank listview). The code above puts that in front of my real view right before the app goes into the background. So, when you come back to the app that is all you see. Voila.