mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-09 00:13:45 +01:00
Launch BGTaskScheduler on a background thread
This commit is contained in:
parent
c590e2d136
commit
84ab745e06
@ -317,12 +317,17 @@ private extension AppDelegate {
|
|||||||
func scheduleBackgroundFeedRefresh() {
|
func scheduleBackgroundFeedRefresh() {
|
||||||
let request = BGAppRefreshTaskRequest(identifier: "com.ranchero.NetNewsWire.FeedRefresh")
|
let request = BGAppRefreshTaskRequest(identifier: "com.ranchero.NetNewsWire.FeedRefresh")
|
||||||
request.earliestBeginDate = Date(timeIntervalSinceNow: AppDefaults.refreshInterval.inSeconds())
|
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 {
|
do {
|
||||||
try BGTaskScheduler.shared.submit(request)
|
try BGTaskScheduler.shared.submit(request)
|
||||||
} catch {
|
} catch {
|
||||||
os_log(.error, log: self.log, "Could not schedule app refresh: %@", error.localizedDescription)
|
os_log(.error, log: self.log, "Could not schedule app refresh: %@", error.localizedDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Performs background feed refresh.
|
/// Performs background feed refresh.
|
||||||
/// - Parameter task: `BGAppRefreshTask`
|
/// - Parameter task: `BGAppRefreshTask`
|
||||||
|
Loading…
Reference in New Issue
Block a user