Automatically exit my application after 10 minutes of non interactions
An example would be if a user sat their 开发者_Go百科phone down with my application open and running but there had been no interactions with the application in the last ten minutes, the user should be logged out and have to sign in again. Is this a parameter that can be defined?
There is no pre-defined parameter. You have to check yourself using a timer method and/or by recording the time of the last user interaction.
It's perfectly legal for an app to display its login UIView (again) after 10 minutes, but don't try to exit the app instead.
Quitting an active app, without user action/notification is considered bad form. However, if you must...
When your application starts, start a timer (NSTimer).
Instrument every method in your application to call a timer_reset function.
After 10 minutes call exit (0);
Have a look at the various NSTimer methods.
精彩评论