I need to show a popup every time when i open the app after 20 sec.
code: with this code i can show popup only when i open the app first time after 20 sec.. but i need to show the same when i close the app and open again.. how to do that? please guide me.
var timer = Timer()
override func viewDidLoad() {
timer = Timer.scheduledTimer(timeInterval: 20.0, target: self, selector: #selector(displayAlert), userInfo: nil, repeats: false)
}
@objc func displayAlert()
{
print("after 20 sec")
showPopup()
}
2
Answers
And if you use a DispatchQueue:
You want to register for notification when your app becomes active…
For example: