Launch BGTaskScheduler on a background thread

This commit is contained in:
Maurice Parker 2019-11-05 19:14:26 -06:00
parent c590e2d136
commit 84ab745e06

View File

@ -317,12 +317,17 @@ private extension AppDelegate {
func scheduleBackgroundFeedRefresh() {
let request = BGAppRefreshTaskRequest(identifier: "com.ranchero.NetNewsWire.FeedRefresh")
request.earliestBeginDate = Date(timeIntervalSinceNow: AppDefaults.refreshInterval.inSeconds())
// We send this to a background queue because as of 11/05/19 on iOS 13.2 the call to the
// task scheduler can hang indefinitely.
DispatchQueue.global(qos: .background).async {
do {
try BGTaskScheduler.shared.submit(request)
} catch {
os_log(.error, log: self.log, "Could not schedule app refresh: %@", error.localizedDescription)
}
}
}
/// Performs background feed refresh.
/// - Parameter task: `BGAppRefreshTask`