我只想在任何给定时间在我的锁定屏幕上显示一个本地 iOS 通知。
在特定通知上调用 cancelLocalNotification
似乎是一种笨拙的方法(在 iOS10 中已弃用)。有没有办法在推送新的本地重复通知之前删除所有通知?
最佳答案
您可以调用 UIApplication
方法 - cancelAllLocalNotifications
。
它在 iOS 10 中已弃用,因为 iOS 10 具有新的 UNNotification
类。
如果您使用这些 - 您可以使用 UNUserNotificationCenter
方法 removeAllPendingNotificationRequests
以及 removeAllDeliveredNotifications
来删除已经发送的通知。
关于ios - 从 Swift 3 中的锁屏清除本地通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41212985/