I would like to show a popup only once per day in my app and if the user has already seen the popup, then, do not show it again for that day. I was struggling for a while and decided to ask for some help here :)
Update
Here is the code I have wrote so far:
func showPopupOncePerDay() -> Bool {
let lastPopup = UserDefaults.standard.double(forKey: "lastPopup")
let lastPopupDate = Date(timeIntervalSinceNow: lastPopup)
let lastPopupIsToday = NSCalendar.current.isDateInToday(lastPopupDate)
if !lastPopupIsToday {
navigator.showAlertPopup()
}
UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: "lastPopup")
return true
}