diff --git a/deltachat-ios/AppDelegate.swift b/deltachat-ios/AppDelegate.swift index 9c8ff3cf7..e12e1eeb5 100644 --- a/deltachat-ios/AppDelegate.swift +++ b/deltachat-ios/AppDelegate.swift @@ -284,6 +284,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD logger.info("➡️ applicationDidBecomeActive") UserDefaults.setMainIoRunning() applicationInForeground = true + NotificationManager.updateApplicationIconBadge() } func applicationWillResignActive(_: UIApplication) { diff --git a/deltachat-ios/Helper/NotificationManager.swift b/deltachat-ios/Helper/NotificationManager.swift index e9161cf89..1bc348b97 100644 --- a/deltachat-ios/Helper/NotificationManager.swift +++ b/deltachat-ios/Helper/NotificationManager.swift @@ -24,7 +24,15 @@ public class NotificationManager { public static func updateApplicationIconBadge(forceZero: Bool = false) { DispatchQueue.main.async { - UIApplication.shared.applicationIconBadgeNumber = forceZero ? 0 : DcAccounts.shared.getFreshMessageCount() + let number = forceZero ? 0 : DcAccounts.shared.getFreshMessageCount() + + UIApplication.shared.applicationIconBadgeNumber = number + + if let appDelegate = UIApplication.shared.delegate as? AppDelegate, + let appCoordinator = appDelegate.appCoordinator, + let chatsNavigationController = appCoordinator.tabBarController.viewControllers?[appCoordinator.chatsTab] { + chatsNavigationController.tabBarItem.badgeValue = number > 0 ? "\(number)" : nil + } } }