Cancel network activity when told to shutdown by the OS. Issue #1232

This commit is contained in:
Maurice Parker
2019-11-04 20:24:21 -06:00
parent 219e5751a1
commit c6e3ed6692
14 changed files with 232 additions and 71 deletions

View File

@@ -109,6 +109,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
func applicationWillTerminate(_ application: UIApplication) {
shuttingDown = true
AccountManager.shared.suspendAll()
}
// MARK: Notifications
@@ -243,7 +244,7 @@ private extension AppDelegate {
func waitForProgressToFinish() {
let completeProcessing = { [unowned self] in
AccountManager.shared.saveAll()
AccountManager.shared.suspendAll()
UIApplication.shared.endBackgroundTask(self.waitBackgroundUpdateTask)
self.waitBackgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
}

View File

@@ -16,7 +16,11 @@ struct ErrorHandler {
public static func present(_ viewController: UIViewController) -> (Error) -> () {
return { [weak viewController] error in
viewController?.presentError(error)
if UIApplication.shared.applicationState == .active {
viewController?.presentError(error)
} else {
ErrorHandler.log(error)
}
}
}