开发者

Autologout iphone app

开发者 https://www.devze.com 2023-02-20 23:18 出处:网络
I\'m looking to make an iphone that will log a user out of a session once the app has been either idle in the foreground or in开发者_高级运维 the background for a specified period of time.

I'm looking to make an iphone that will log a user out of a session once the app has been either idle in the foreground or in开发者_高级运维 the background for a specified period of time.

I'm guessing that I should use an NSTimer, but I don't know where to start it. How can I tell when a user has been idle when the app is in the foreground? I'm guessing that it should be a UIApplicationDelegate method?

Any suggestions? Thanks.


If you want to auto logout when the application enters background, try looking at the application delegate methods. For example, there is a applicationDidEnterBackground method, and applicationWillTerminate could also be helpful. This is where you could implement your automatic logout. If you want to logout after the application is in the background for a certain period of time, then you need to enable your application to run in the background. To do that just go to the application info.plist file and add a new field "Application does not run in background". Make sure it is UNchecked. Then in the applicationDidEnterBackground method add an NSTimer, and after a certain period of time you can logout.

0

精彩评论

暂无评论...
验证码 换一张
取 消