diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index ca35cfd8b..a12247045 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -732,7 +732,7 @@ static NSTimeInterval launchStartedAt; OWSLogInfo(@"running post launch block for unregistered user."); // Unregistered user should have no unread messages. e.g. if you delete your account. - [SignalApp clearAllNotifications]; + [AppEnvironment.shared.notificationPresenter clearAllNotifications]; [self.socketManager requestSocketOpen]; @@ -791,6 +791,7 @@ static NSTimeInterval launchStartedAt; OWSLogWarn(@"applicationWillResignActive."); [self updateShouldEnableLandscape]; + [self clearAllNotificationsAndRestoreBadgeCount]; [DDLog flushLog]; } @@ -799,8 +800,8 @@ static NSTimeInterval launchStartedAt; { OWSAssertIsOnMainThread(); - [SignalApp clearAllNotifications]; [AppReadiness runNowOrWhenAppDidBecomeReady:^{ + [AppEnvironment.shared.notificationPresenter clearAllNotifications]; [OWSMessageUtils.sharedManager updateApplicationBadgeCount]; }]; } diff --git a/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift b/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift index 5ec257521..cc326e3b3 100644 --- a/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift +++ b/Signal/src/UserInterface/Notifications/LegacyNotificationsAdaptee.swift @@ -222,6 +222,13 @@ extension LegacyNotificationPresenterAdaptee: NotificationPresenterAdaptee { for (_, notification) in notifications { cancelNotification(notification) } + // This will cancel all "scheduled" local notifications that haven't + // been presented yet. + UIApplication.shared.cancelAllLocalNotifications() + // To clear all already presented local notifications, we need to + // set the app badge number to zero after setting it to a non-zero value. + UIApplication.shared.applicationIconBadgeNumber = 1 + UIApplication.shared.applicationIconBadgeNumber = 0 } } diff --git a/Signal/src/environment/SignalApp.h b/Signal/src/environment/SignalApp.h index ebf2ae8a4..b3b5fb9dc 100644 --- a/Signal/src/environment/SignalApp.h +++ b/Signal/src/environment/SignalApp.h @@ -50,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN + (void)resetAppData; -+ (void)clearAllNotifications; - (void)showHomeView; diff --git a/Signal/src/environment/SignalApp.m b/Signal/src/environment/SignalApp.m index 1b7f2a2df..1eb5f764b 100644 --- a/Signal/src/environment/SignalApp.m +++ b/Signal/src/environment/SignalApp.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "SignalApp.h" @@ -138,26 +138,12 @@ NS_ASSUME_NONNULL_BEGIN [OWSStorage resetAllStorage]; [OWSUserProfile resetProfileStorage]; [Environment.shared.preferences clear]; - - [self clearAllNotifications]; + [AppEnvironment.shared.notificationPresenter clearAllNotifications]; [DebugLogger.sharedLogger wipeLogs]; exit(0); } -+ (void)clearAllNotifications -{ - OWSLogInfo(@"clearAllNotifications."); - - // This will cancel all "scheduled" local notifications that haven't - // been presented yet. - [UIApplication.sharedApplication cancelAllLocalNotifications]; - // To clear all already presented local notifications, we need to - // set the app badge number to zero after setting it to a non-zero value. - [UIApplication sharedApplication].applicationIconBadgeNumber = 1; - [UIApplication sharedApplication].applicationIconBadgeNumber = 0; -} - - (void)showHomeView { HomeViewController *homeView = [HomeViewController new];