iOS: Hiding sensitive information on the screen when app is backgrounded
Asked Answered
H

2

6

When a foreground app gets backgrounded (e.g. Home button gets pressed), how can I change elements on the topmost view controller prior to when iOS takes a snapshot of it and starts the animation to show the next screen?

I ask because I'm writing an app requiring HIPAA compliance, and I am concerned that the snapshot that the OS takes in order to do this animation sometimes contains sensitive data which should not be visible even for a split second when the app gets foregrounded later.

I'm aware that view controllers have lifecycle methods such as viewWillDisappear which might be usable, but I have a lot of controllers and I'd rather just have something in my App Delegate to handle this (e.g. by adding an opaque full-screen UIImageView overlay) rather than having to write custom code for this in every last controller.

I tried putting overlay-generating code in applicationWillResignActive, and I've been digging with Apple's docs and Google, but it's not working. I suspect the screenshot gets taken before the app has a chance to update the screen.

Thanks!

Herv answered 25/9, 2012 at 18:38 Comment(4)
Have you tried changing the views in applicationWillEnterForeground? Or is that also a static animation until the entire resume zoom animation is done?Inherited
Well, it's working now. I'm not sure if it's because I added my UIImageView to self.window rather than pulling the topViewController out of my navigationController and adding it there, or if it's because I put the code in applicationDidEnterBackground rather than applicationWillResignActive. Anyway, the sensitive info is no longer displayed when foregrounding. I'll try to dig into this and write a more concise answer as soon as SO will let me.Herv
Without being fully up on HIPAA compliance, is it going to be an issue that users can take screenshots at any time? There's no known solution to that as far as I'm aware.Adman
Good thought, Tommy. We don't expect this to be an issue in our case. Staff will either have full control over the iPad and will be educated on this issue, or it will be in a kiosk enclosure so patients can't access the power button. IIRC, the Photos app can also be forbidden using security settings. Will have to R&D that.Herv
H
2

I believe the answer is to not concern oneself with changing what's on the screen before the backgrounding animation begins, but to simply modify what's displayed on the screen once the app enters the background (i.e. inside of applicationDidEnterBackground: in your App Delegate.) This solved my problem.

My UIImageView overlay idea worked here, although I decided just to pop to the root view controller instead. Simpler that way. My root view doesn't have any sensitive info.

Here's what it looks like:

-(void)applicationDidEnterBackground:(UIApplication *)application {

    UINavigationController *navigationController = 
        (UINavigationController *)self.window.rootViewController;
    [navigationController popToRootViewControllerAnimated:NO];

    ...
}
Herv answered 27/9, 2012 at 0:26 Comment(0)
T
4

Not sure about HIPAA's requirements about backgrounding and possibly leaving the user logged in for someone else to resume, but the safest sounds like it would be to add a key UIApplicationExitsOnSuspend with a boolean value of YES to info.plist.

That will prevent the app from backgrounding entirely, and restarts it (possibly triggering a login procedure) every time you go back to it.

Most (if not all) mobile banking applications I've tested do this for safety reasons.

Triumphal answered 25/9, 2012 at 18:50 Comment(1)
That's a good idea, although I already found a solution that lets me keep backgrounding. Good as a last resort though.Herv
H
2

I believe the answer is to not concern oneself with changing what's on the screen before the backgrounding animation begins, but to simply modify what's displayed on the screen once the app enters the background (i.e. inside of applicationDidEnterBackground: in your App Delegate.) This solved my problem.

My UIImageView overlay idea worked here, although I decided just to pop to the root view controller instead. Simpler that way. My root view doesn't have any sensitive info.

Here's what it looks like:

-(void)applicationDidEnterBackground:(UIApplication *)application {

    UINavigationController *navigationController = 
        (UINavigationController *)self.window.rootViewController;
    [navigationController popToRootViewControllerAnimated:NO];

    ...
}
Herv answered 27/9, 2012 at 0:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.