gbusto / BrickBreak

An attempt to make a game like "Ballz" or "Bricks and Balls".
1 stars 0 forks source link

Update Notifications for Background/Foreground/Terminate to Use AppDelegate Functions #608

Closed gbusto closed 5 years ago

gbusto commented 5 years ago

Here is a link to an example of how to use the functions in AppDelegate to track app level events: https://stackoverflow.com/questions/49030947/app-will-terminate-notification.

init() {
  NotificationCenter.default.addObserver(self,
      selector: #selector(applicationWillTerminate(notification:)),
      name: UIApplication.willTerminateNotification,
      object: nil)
}

@objc func applicationWillTerminate(notification: Notification) {
  // Notification received.
}

deinit {
  NotificationCenter.default.removeObserver(self)
}