Last active
April 5, 2022 23:31
-
-
Save dbonates/eee09c22a876cb321599aef2600c6280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// WillianViewController.swift | |
// TempApp | |
// | |
// Created by Daniel Bonates on 05/04/22. | |
// | |
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
NotificationCenter.default.addObserver(self, selector: #selector(appActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil) | |
NotificationCenter.default.addObserver(self, selector: #selector(appWillBeInactive(_:)), name: UIApplication.willResignActiveNotification, object: nil) | |
NotificationCenter.default.addObserver(self, selector: #selector(goneBg(_:)), name: UIApplication.didEnterBackgroundNotification, object: nil) | |
NotificationCenter.default.addObserver(self, selector: #selector(backToFront(_:)), name: UIApplication.willEnterForegroundNotification, object: nil) | |
} | |
@objc func appActive(_ sender: NSNotification) { | |
print("👻 app foi ativada pelo iOS") | |
} | |
@objc func appWillBeInactive(_ sender: NSNotification) { | |
print("👻 app vai passar pra inativa") | |
} | |
@objc func goneBg(_ sender: NSNotification) { | |
print("👻 app foi pra background") | |
} | |
@objc func backToFront(_ sender: NSNotification) { | |
print("👻 app voltou pra tela") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment