如何停止来自应用程序的通知[重复]

Posted

技术标签:

【中文标题】如何停止来自应用程序的通知[重复]【英文标题】:How to stop Notifications from the app [duplicate] 【发布时间】:2016-03-19 21:53:51 【问题描述】:

在开关内部,我有一个触发通知的触发器,它能够自我重复。开关关闭时如何让它停止?

let notification = UILocalNotification()
notification.fireDate = NSDate(timeIntervalSinceNow: 5)
notification.repeatInterval = NSCalendarUnit.Minute
notification.alertBody = "Please Look at me"
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["CustomField1": "w00t"]
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else  return 

【问题讨论】:

【参考方案1】:

您可以使用

取消所有本地通知
cancelAllLocalNotifications

或使用

浏览预定通知列表
scheduledLocalNotifications

并取消那个特定的(通过指定通知的“userInfo”字段来标记)。

【讨论】:

以上是关于如何停止来自应用程序的通知[重复]的主要内容,如果未能解决你的问题,请参考以下文章