Search code examples
iosxcodeuinavigationcontrolleruitabbarcontrolleruiapplicationdelegate

AutoLock an App after a Certain Number of Minutes


My question..not even sure if this is possible but curious from others...

I have an app that will prompt a use for a password each time the user opens or brings back from the background. Works fine.

Due to the sensitivity of the data I'd like to be able to create an auto-lock type feature that after a certain number of minutes of inactivity will prompt the user to either enter data or make go into the background. If no response within say 30 seconds I make the app enter the background (it's just the type of data that is left on the screen can have horrible consequences if found by the wrong hands and we all know circumstances happen where we leave our phone unguarded).

Is this even possible? And if so..some general thoughts to get me going.

The app is a tab bar application with navigation controllers as each of the tab bar items. It's very simple.

Thanks.


Solution

  • As far as I know, there's no way to only go into the background voluntarily. The best approximation might be to request the opening of some URL so that you were replaced with the browser.

    Other than that, you can have code that cancels a timer and restarts it for whatever number of minutes you want. It would be called on each 'activity'. If the timer ever expires, push a modal view controller for the information you want as an unlock. Deciding on, and taking care of, all the things that might be considered activity may require some thought. :)