Mit diesen Codzeilen kann man erkennen, ob eine App in den Hintergund geschoben wird.
override func viewDidLoad() {
super.viewDidLoad()
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
}
@objc func appMovedToBackground() {
print ("App moved to Background")
}
Über den Autor