Skip to content

Instantly share code, notes, and snippets.

@gustafnilklint
Created February 5, 2020 13:03
Show Gist options
  • Save gustafnilklint/9ee7356f4c1d31406bc9774679592e93 to your computer and use it in GitHub Desktop.
Save gustafnilklint/9ee7356f4c1d31406bc9774679592e93 to your computer and use it in GitHub Desktop.
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
for task in backgroundTasks {
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
BackgroundService.shared.updateContent()
backgroundTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
BackgroundService.shared.handleDownload(urlSessionTask)
default:
task.setTaskCompletedWithSnapshot(false)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment