【发布时间】:2016-12-18 21:18:28
【问题描述】:
我只想在任何给定时间在我的锁定屏幕上显示一个本地 iOS 通知。
在特定通知上调用 cancelLocalNotification 似乎是一种笨拙的方法(在 iOS10 中已弃用)。有什么方法可以在推送新的本地重复通知之前删除所有通知?
【问题讨论】:
标签: ios iphone swift push-notification apple-push-notifications
我只想在任何给定时间在我的锁定屏幕上显示一个本地 iOS 通知。
在特定通知上调用 cancelLocalNotification 似乎是一种笨拙的方法(在 iOS10 中已弃用)。有什么方法可以在推送新的本地重复通知之前删除所有通知?
【问题讨论】:
标签: ios iphone swift push-notification apple-push-notifications
您可以调用 UIApplication 方法 - cancelAllLocalNotifications。
它在 iOS 10 中已弃用,因为 iOS 10 具有新的 UNNotification 类。
如果你使用这些 - 你可以使用 UNUserNotificationCenter 方法 removeAllPendingNotificationRequests 和 removeAllDeliveredNotifications 来删除已经发送的通知。
【讨论】:
UINotification - 也可以使用 UINotificationCenter. removeAllDeliveredNotifications 删除所有已发送的通知。