Merge branch 'charlesmchen/debugNotifications2'
This commit is contained in:
commit
ca03203b95
@ -87,8 +87,6 @@ static NSTimeInterval launchStartedAt;
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
DDLogWarn(@"%@ applicationWillEnterForeground.", self.logTag);
|
||||
|
||||
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
||||
}
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
|
||||
@ -533,7 +531,7 @@ static NSTimeInterval launchStartedAt;
|
||||
// When opening the app from a notification,
|
||||
// AppDelegate.didReceiveLocalNotification will always
|
||||
// be called _before_ we become active.
|
||||
[application cancelAllLocalNotifications];
|
||||
[self clearAllNotificationsAndRestoreBadgeCount];
|
||||
|
||||
DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.logTag);
|
||||
}
|
||||
@ -591,7 +589,7 @@ static NSTimeInterval launchStartedAt;
|
||||
DDLogInfo(@"%@ running post launch block for unregistered user.", self.logTag);
|
||||
|
||||
// Unregistered user should have no unread messages. e.g. if you delete your account.
|
||||
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
||||
[SignalApp clearAllNotifications];
|
||||
|
||||
[TSSocketManager requestSocketOpen];
|
||||
|
||||
@ -653,11 +651,21 @@ static NSTimeInterval launchStartedAt;
|
||||
DDLogWarn(@"%@ applicationWillResignActive.", self.logTag);
|
||||
|
||||
// Clear all notifications whenever we become inactive.
|
||||
[application cancelAllLocalNotifications];
|
||||
[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 {
|
||||
|
||||
@ -44,4 +44,6 @@
|
||||
|
||||
+ (void)resetAppData;
|
||||
|
||||
+ (void)clearAllNotifications;
|
||||
|
||||
@end
|
||||
|
||||
@ -227,10 +227,24 @@
|
||||
[OWSStorage resetAllStorage];
|
||||
[[OWSProfileManager sharedManager] resetProfileStorage];
|
||||
[Environment.preferences clear];
|
||||
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
||||
|
||||
[self clearAllNotifications];
|
||||
|
||||
[DebugLogger.sharedLogger wipeLogs];
|
||||
exit(0);
|
||||
}
|
||||
|
||||
+ (void)clearAllNotifications
|
||||
{
|
||||
DDLogInfo(@"%@ clearAllNotifications.", self.logTag);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -95,7 +95,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[CurrentAppContext() setMainAppBadgeNumber:numberOfItems];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Loading…
Reference in New Issue
Block a user