6

I need to add a 4 digit pin view controller that would "hover" over my app's main window and prevent users who do not know the pin from browsing data within the app.

I'm interested if there are any demo projects or open source projects that accomplish this functionality (key clicks, automatically changing focus, displaying a static glossy keyboard, lock after x amount of seconds).

Thank you for your input!

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
  • After refining my web search, I found this answer: [http://stackoverflow.com/questions/2891138/password-protect-iphone-app][1] [1]: http://stackoverflow.com/questions/2891138/password-protect-iphone-app – Alex Stone Jul 10 '12 at 16:52

2 Answers2

5

not sure of any demo apps, but you have hooks to do this like...

app delegates 'applicationWillEnterForeground' and 'applicationDidBecomeActive'

also might matter if your app is enabled to run in background or not how you go about implementing it.

In my app I have it set up to navigate the user to home screen anytime the app becomes active/enters foreground. The home screen controller then determines if the user is still logged in/active and if they aren't it pushes a login view controller on the stack.

Augie
  • 1,341
  • 1
  • 11
  • 18
2

Making my own custom alert view, somewhat following this tutorial, I was able to make a PIN-entry view that covers the entire window, thus absorbing all input. I then put code in applicationWillResignActive and applicationDidBecomeActive to determine how long the app has been minimized for, in order to present the PIN entry window based on the user's preference settings. Don't forget, you want to store the PIN in a secure manner, I recommend using the built-in keychain.

Dan F
  • 17,654
  • 5
  • 72
  • 110
  • Very good suggestion! I was thinking of running a background timer to determine when to "lock" the app, but comparing 2 dates is so much easier. – Alex Stone Jul 11 '12 at 14:04