From 5e0c10a1a9cce1abf8eb891192e18955918da328 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 12 Feb 2019 17:11:27 -0700 Subject: [PATCH] remove any lingering legacy notifications in modern notification adapter --- .../Notifications/LegacyNotificationsAdaptee.swift | 4 ++++ .../Notifications/UserNotificationsAdaptee.swift | 1 + 2 files changed, 5 insertions(+) diff --git a/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift b/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift index cc326e3b3..f44aac478 100644 --- a/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift +++ b/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift @@ -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() diff --git a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift index 6b037c8aa..412ed633c 100644 --- a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift +++ b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift @@ -181,6 +181,7 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee { AssertIsOnMainThread() notificationCenter.removeAllPendingNotificationRequests() notificationCenter.removeAllDeliveredNotifications() + LegacyNotificationPresenterAdaptee.clearExistingNotifications() } func shouldPresentNotification(category: AppNotificationCategory, userInfo: [AnyHashable: Any]) -> Bool {