ios - 如何停止来自应用程序的通知

标签 ios swift swift2 uilocalnotification

<分区>

在 switch 中,我有一个通知触发器,可以重复自身。如何让它在开关关闭时停止?

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 }

最佳答案

您可以使用

取消所有本地通知
cancelAllLocalNotifications

或使用

浏览预定通知列表
scheduledLocalNotifications

并取消该特定通知(通过指定通知的“userInfo”字段进行标记)。

关于ios - 如何停止来自应用程序的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36107662/

相关文章:

ios - 如何在 Swift 中实现 UIPageViewController 委托(delegate)的 transitionCompleted?

swift - watchOS2 animateWithDuration 启动缓慢并加速

iOS segue 两次屏幕

arrays - 将项目插入空数组

ios - 选择时会膨胀和收缩的不同单元格高度

ios - 无法从 pod 框架内部登录

ios - 使用动画影响更改 iOS 设备状态栏

ios - 监控 ibeacon 时替代 didexitregion

android - Android/iOS 应用程序内浏览器上的证书固定

ios - 为什么在 Collection View 单元格中以编程方式创建的按钮需要是惰性变量?