Skip to content

Instantly share code, notes, and snippets.

@mecid
Created July 3, 2019 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mecid/0fbec7c9fb31662f02dd2a289e3e1e05 to your computer and use it in GitHub Desktop.
Save mecid/0fbec7c9fb31662f02dd2a289e3e1e05 to your computer and use it in GitHub Desktop.
func applicationDidEnterBackground(_ application: UIApplication) {
scheduleAppRefresh()
}
private func scheduleAppRefresh() {
do {
let request = BGAppRefreshTaskRequest(identifier: "pl.snowdog.example.refresh")
request.earliestBeginDate = Date(timeIntervalSinceNow: 3600)
try BGTaskScheduler.shared.submit(request)
} catch {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment