I have an app in Xcode which handles sensitive data. I would like to terminate the app / exit forcefully if there is inactivity for 5 mins. Can someone please tell me how to do this?
Thank you!
I have an app in Xcode which handles sensitive data. I would like to
Share
Click here for a tutorial on how to make a timer. Every action that the user takes, reset the timer. When the 5 minutes are up, you can use
exit(0).However, this method of programatically closing your app is discouraged by Apple, so use it at your own discretion.
Edit: In order to stop the timer, you need to store a pointer to the timer that you create, and then call:
Edit 2: An alternative to using
exit(0)would be to make a almost blank screen except for some text that states:Make this screen appear once the timer gets to 5 minutes. Therefore, the user can’t do anything on the app but look at the screen, or exit the app.