From 889350af60d0f92b3636827c7ecfd010cd135ba7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 1 Feb 2025 20:36:18 -0800 Subject: [PATCH] Make misc. modernization tweaks. --- iOS/AppDelegate.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index ffdd80af2..076191a98 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -69,15 +69,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC CacheCleaner.purgeIfNecessary() initializeHomeScreenQuickActions() - DispatchQueue.main.async { - self.unreadCount = AccountManager.shared.unreadCount - } - - UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in - if granted { - DispatchQueue.main.async { - UIApplication.shared.registerForRemoteNotifications() - } + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { granted, _ in + guard granted else { return } + Task { @MainActor in + UIApplication.shared.registerForRemoteNotifications() } } @@ -123,6 +118,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC if UIDevice.current.userInterfaceIdiom == .pad && AppDefaults.isFirstRun { rootSplitViewController.show(.primary) } + + // Update unread count. + self.unreadCount = AccountManager.shared.unreadCount } return true