I scheduled a local notification that should be activated after several hours without the user using the app. The problem I am having is that once it fires, the notification is repeated constantly until the app goes on the foreground. I would like for it to appear once only.
func applicationDidEnterBackground(application: UIApplication) {
localNotification.fireDate = NSDate(timeIntervalSinceNow: (86400)*3)
localNotification.alertTitle = "Te Extrañamos"
localNotification.alertBody = "No olvides tu estudio en Momentos de Tora"
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
UIApplication.sharedApplication().cancelLocalNotification(localNotification)
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}
Thanks in advance for your help.