Using the NotificationCenter of iOS, which can be very powerful, you are able to intercept certain app-wide events:
NotificationCenter.default.addObserver(
        self,
        selector: #selector(ViewController.do(_:)),
        name: NSNotification.Name.UIApplicationDidBecomeActive,
        o...