diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 9e4da121e..4f7a66363 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -531,7 +531,7 @@ static NSTimeInterval launchStartedAt; // When opening the app from a notification, // AppDelegate.didReceiveLocalNotification will always // be called _before_ we become active. - [SignalApp clearAllNotifications]; + [self clearAllNotificationsAndRestoreBadgeCount]; DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.logTag); } @@ -651,11 +651,21 @@ static NSTimeInterval launchStartedAt; DDLogWarn(@"%@ applicationWillResignActive.", self.logTag); // Clear all notifications whenever we become inactive. - [SignalApp clearAllNotifications]; + [self clearAllNotificationsAndRestoreBadgeCount]; [DDLog flushLog]; } +- (void)clearAllNotificationsAndRestoreBadgeCount +{ + OWSAssertIsOnMainThread(); + + [SignalApp clearAllNotifications]; + [AppReadiness runNowOrWhenAppIsReady:^{ + [OWSMessageUtils.sharedManager updateApplicationBadgeCount]; + }]; +} + - (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler { diff --git a/SignalServiceKit/src/Messages/OWSMessageUtils.m b/SignalServiceKit/src/Messages/OWSMessageUtils.m index 165e11f67..b6c631cac 100644 --- a/SignalServiceKit/src/Messages/OWSMessageUtils.m +++ b/SignalServiceKit/src/Messages/OWSMessageUtils.m @@ -95,7 +95,6 @@ NS_ASSUME_NONNULL_BEGIN [CurrentAppContext() setMainAppBadgeNumber:numberOfItems]; } - @end NS_ASSUME_NONNULL_END