0

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.

holster
  • 47
  • 7
  • Apple usually suggests that users with that sensitive of data on their phones should have a passcode lock. – ricochet1k Apr 25 '12 at 17:50
  • correct..however I don't make the assumption that they do..which is why I have gone this route..all my test users use the password feature..I'm looking to enhance this some more. – holster Apr 25 '12 at 23:36

3 Answers3

2

You can open a URL. Either a normal HTTP URL that will open Safari, or a URL handled by another application. But that's fairly bad design, and it's possible Apple will have a problem with it. You're only supposed to control the behaviour of your application, not the system.

I don't understand what you expect to gain from this though. Detecting inactivity, fine. But why not just put an opaque view over the top of the sensitive data, hiding everything and providing a button to unlock the application? Why do you specifically need the application to go into the background?

Jim
  • 72,985
  • 14
  • 101
  • 108
  • I'm afraid I don't understand why I would open a URL? I want to detect inactivity and basically make the app require the password again. Just like apple does with the phone. I don't want to shut down the app in case the user was in the middle of entering data but got distracted. So it doesn't have to go into the background per so it just needs to prompt for a password like I do when it comes back from the background. – holster Apr 25 '12 at 23:32
  • opps...sorry..so...I guess I'm asking how do I detect for inactivity? – holster Apr 25 '12 at 23:32
0

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. :)

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
0

Every time the user interacts with your app call a method like this

[lockoutTimer invalidate]  
lockoutTimer =  [NSTimer scheduledTimerWithTimeInterval:(30) target:self selector:@selector( method to ask the user to either enter data or make go a website) userInfo:nil repeats:YES];

go to web site code : [[UIApplication sharedApplication] openURL:[NSURL URLWithString: myWebsiteURL ]];

Jason McTaggart
  • 878
  • 1
  • 7
  • 18