Merge branch 'mkirk/clear-notifications' into release/2.36.0

pull/2/head
Michael Kirk 6 years ago
commit d65353874e

@ -732,7 +732,7 @@ static NSTimeInterval launchStartedAt;
OWSLogInfo(@"running post launch block for unregistered user."); OWSLogInfo(@"running post launch block for unregistered user.");
// Unregistered user should have no unread messages. e.g. if you delete your account. // Unregistered user should have no unread messages. e.g. if you delete your account.
[SignalApp clearAllNotifications]; [AppEnvironment.shared.notificationPresenter clearAllNotifications];
[self.socketManager requestSocketOpen]; [self.socketManager requestSocketOpen];
@ -791,6 +791,7 @@ static NSTimeInterval launchStartedAt;
OWSLogWarn(@"applicationWillResignActive."); OWSLogWarn(@"applicationWillResignActive.");
[self updateShouldEnableLandscape]; [self updateShouldEnableLandscape];
[self clearAllNotificationsAndRestoreBadgeCount];
[DDLog flushLog]; [DDLog flushLog];
} }
@ -799,8 +800,8 @@ static NSTimeInterval launchStartedAt;
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[SignalApp clearAllNotifications];
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
[AppEnvironment.shared.notificationPresenter clearAllNotifications];
[OWSMessageUtils.sharedManager updateApplicationBadgeCount]; [OWSMessageUtils.sharedManager updateApplicationBadgeCount];
}]; }];
} }

@ -222,6 +222,17 @@ extension LegacyNotificationPresenterAdaptee: NotificationPresenterAdaptee {
for (_, notification) in notifications { for (_, notification) in notifications {
cancelNotification(notification) 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()
// 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
} }
} }

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

@ -50,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)resetAppData; + (void)resetAppData;
+ (void)clearAllNotifications;
- (void)showHomeView; - (void)showHomeView;

@ -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" #import "SignalApp.h"
@ -138,26 +138,12 @@ NS_ASSUME_NONNULL_BEGIN
[OWSStorage resetAllStorage]; [OWSStorage resetAllStorage];
[OWSUserProfile resetProfileStorage]; [OWSUserProfile resetProfileStorage];
[Environment.shared.preferences clear]; [Environment.shared.preferences clear];
[AppEnvironment.shared.notificationPresenter clearAllNotifications];
[self clearAllNotifications];
[DebugLogger.sharedLogger wipeLogs]; [DebugLogger.sharedLogger wipeLogs];
exit(0); 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 - (void)showHomeView
{ {
HomeViewController *homeView = [HomeViewController new]; HomeViewController *homeView = [HomeViewController new];

Loading…
Cancel
Save