Autologout iphone app

I am looking for an iphone that will log the user out of the session after the application is either idle in the foreground or in the background for a certain period of time.

I guess I should use NSTimer, but I don't know where to start. How to know when the user is idle, when the application is in the foreground? I assume this should be the UIApplicationDelegate method?

Any suggestions? Thanks.

+4
source share
1 answer

If you want to automatically log out when the application enters the background, try to learn how to delegate the application. For example, there is a method applicationDidEnterBackground , as well as applicationWillTerminate . Here you can log out automatically. If you want to exit the system after the application is in the background for a certain period of time, you need to enable the application to work in the background. To do this, simply go to the application info.plist file and add a new field "Application does not work in the background." Make sure it is not verified. Then, in the applicationDidEnterBackground method, add NSTimer, and after a certain period of time you can exit the system.

+2
source

Source: https://habr.com/ru/post/1346129/


All Articles