Fix crash that could happen on launch because the background task wasn't registered before it was triggered

This commit is contained in:
Maurice Parker 2019-08-14 19:48:18 -05:00
parent c21b235c6c
commit 99e2a44eed
1 changed files with 2 additions and 2 deletions

View File

@ -53,6 +53,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
super.init() super.init()
appDelegate = self appDelegate = self
registerBackgroundTasks()
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountRefreshDidFinish(_:)), name: .AccountRefreshDidFinish, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountRefreshDidFinish(_:)), name: .AccountRefreshDidFinish, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
@ -64,8 +66,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
registerBackgroundTasks()
AppDefaults.registerDefaults() AppDefaults.registerDefaults()
let isFirstRun = AppDefaults.isFirstRun let isFirstRun = AppDefaults.isFirstRun
if isFirstRun { if isFirstRun {