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.");
// 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];
}];
}

@ -222,6 +222,17 @@ 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()
// 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()
notificationCenter.removeAllPendingNotificationRequests()
notificationCenter.removeAllDeliveredNotifications()
LegacyNotificationPresenterAdaptee.clearExistingNotifications()
}
func shouldPresentNotification(category: AppNotificationCategory, userInfo: [AnyHashable: Any]) -> Bool {

@ -50,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)resetAppData;
+ (void)clearAllNotifications;
- (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"
@ -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];

Loading…
Cancel
Save