Perform action after inactivity

Hi, I am making an app for public display, and I would like to implement a function that takes the app back to the home page after there has been no interaction for 3 minutes. My home page is its own view controller, so it should be as easy as calling the unwind segue. Any hints on how I can implement this?

You could set an NSTimer, and invalidate and reset it each time the user performs and action. That would result in a lot of calls to reset the timer though (you would have to call it on every single button press in your app).

A possible solution that I think you could use to make that easier, would be to use a custom subclass for your app’s root view. You can override the touch handling methods to also invalidate and reset the timer. As long as you call the super method then they should be along the chain like normal, so rest of the app functionality should be unaffected. Have a look at the UIView documentation, I think hitTest(CGPoint, with: UIEvent?) might be the one you want