Я планирую размещение на основе UILocalNotification
одним нажатием кнопки. Но когда я пытаюсь отменить localNotification, снова нажав ту же кнопку, он не отменяет уведомление.
Я использую UIApplication.sharedApplication().cancelLocalNotification(localNotification)
для отмены локального уведомления на основе запланированного местоположения.
Что я делаю не так?
вот моя реализация
@IBAction func setNotification(sender: UIButton!) {
if sender.tag == 999 {
sender.setImage(UIImage(named: "NotificationFilled")!, forState: .Normal)
sender.tag = 0
regionMonitor() //function where notification get scheduled
} else {
sender.setImage(UIImage(named: "Notification")!, forState: .Normal)
sender.tag = 999 }
что мне нужно ввести в блок else, чтобы уведомление о расписании было отменено. Невозможно очистить все уведомления.
вот блок didEnterRegion
, где я запускаю локальное уведомление
func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
localNotification.regionTriggersOnce = true
localNotification.alertBody = "Qaru is great"
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
NSLog("Entering region")
}