Change to ensure that the app gets suspended when running too long during a background refresh.
This commit is contained in:
parent
f159371967
commit
63428fb2a2
|
@ -301,12 +301,15 @@ private extension AppDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func suspendApplication() {
|
func suspendApplication() {
|
||||||
|
guard !isAnySceneInForeground else { return }
|
||||||
|
|
||||||
CoalescingQueue.standard.performCallsImmediately()
|
CoalescingQueue.standard.performCallsImmediately()
|
||||||
for scene in UIApplication.shared.connectedScenes {
|
for scene in UIApplication.shared.connectedScenes {
|
||||||
if let sceneDelegate = scene.delegate as? SceneDelegate {
|
if let sceneDelegate = scene.delegate as? SceneDelegate {
|
||||||
sceneDelegate.suspend()
|
sceneDelegate.suspend()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AccountManager.shared.saveAll()
|
||||||
AccountManager.shared.suspendAll()
|
AccountManager.shared.suspendAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +357,6 @@ private extension AppDelegate {
|
||||||
AccountManager.shared.resumeAll()
|
AccountManager.shared.resumeAll()
|
||||||
}
|
}
|
||||||
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log) { [unowned self] in
|
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log) { [unowned self] in
|
||||||
AccountManager.shared.saveAll()
|
|
||||||
self.suspendApplication()
|
self.suspendApplication()
|
||||||
os_log("Account refresh operation completed.", log: self.log, type: .info)
|
os_log("Account refresh operation completed.", log: self.log, type: .info)
|
||||||
task?.setTaskCompleted(success: true)
|
task?.setTaskCompleted(success: true)
|
||||||
|
@ -363,6 +365,7 @@ private extension AppDelegate {
|
||||||
|
|
||||||
// set expiration handler
|
// set expiration handler
|
||||||
task.expirationHandler = { [weak task] in
|
task.expirationHandler = { [weak task] in
|
||||||
|
self.suspendApplication()
|
||||||
os_log("Accounts refresh processing terminated for running too long.", log: self.log, type: .info)
|
os_log("Accounts refresh processing terminated for running too long.", log: self.log, type: .info)
|
||||||
task?.setTaskCompleted(success: false)
|
task?.setTaskCompleted(success: false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue