我希望列出计划中的本地通知,以便检查触发日期,并取消其中的一个。
以下是我添加本地通知的方式:
let notification = UILocalNotification()
notification.fireDate = date
notification.alertBody = message
notification.soundName = UILocalNotificationDefaultSoundName
notification.timeZone = NSTimeZone.defaultTimeZone()
这是我列出所有通知以找到好的通知的方法:
for oneEvent in UIApplication.sharedApplication().scheduledLocalNotifications! {
if date == notification.fireDate {
app.cancelLocalNotification(notification)
}
}
问题是我创建了很多通知,但在scheduledLocalNotifications
中始终只有一个通知!
通知已正确触发,但是我无法在scheduledLocalNotifications
变量中检索它们。