I have an iPhone App which allows users to log in and interact with a web service. I would like to have the ability for the user to be automatically logged out after a period of inactivity...more specifically if the App has been in the background for over a period of time (for example 1 hour).

I would ideally like to run a check in the App Delegate method applicationWillEnterForeground that checks how long the app has been in the background and then if it has been over the time allowed, take them to the log in screen.

How would I run this check in the above method? I would appreciate some sample code.

If this is not the best way to achieve my requirements then suggestions also welcome!

Many thanks in advance

Andy