remove any lingering legacy notifications in modern notification adapter

This commit is contained in:
Michael Kirk 2019-02-12 17:11:27 -07:00
parent cb3a36ba3d
commit 5e0c10a1a9
2 changed files with 5 additions and 0 deletions

View file

@ -222,6 +222,10 @@ extension LegacyNotificationPresenterAdaptee: NotificationPresenterAdaptee {
for (_, notification) in notifications {
cancelNotification(notification)
}
type(of: self).clearExistingNotifications()
}
public class func clearExistingNotifications() {
// This will cancel all "scheduled" local notifications that haven't
// been presented yet.
UIApplication.shared.cancelAllLocalNotifications()

View file

@ -181,6 +181,7 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee {
AssertIsOnMainThread()
notificationCenter.removeAllPendingNotificationRequests()
notificationCenter.removeAllDeliveredNotifications()
LegacyNotificationPresenterAdaptee.clearExistingNotifications()
}
func shouldPresentNotification(category: AppNotificationCategory, userInfo: [AnyHashable: Any]) -> Bool {