How can I completely exit the application when the screen lock button is pressed?

I added UIApplicationExitsOnSuspend to my Info.plist and set it to YES . The key will exit my application completely when the home button is pressed. But what about a screen lock? or how can I detect a screen lock event? There is no key named UIApplicationExitsOnScreenLock I want.

+4
source share
2 answers

See the smart workaround in this answer . This seems to be the only way to do this, but it is a hack, so changes in iOS may make it not work.

+1
source

The way out of this does not fit. In applet-applicationWillResignActive :, simply unauthenticate the user or whatever you try to do with a full restart every time. I don’t know what a steel safe is, but it probably doesn’t.

Or maybe check the UIApplicationProtectedDataWillBecomeUnavailable notification? However, it is sent only when the device is locked, if the user has a password. If you use NSFileProtectionComplete in your "secret" files, close them when you are inactive.

0
source

All Articles