That seems to be the replacement for .backgroundTask(.appRefresh(...))
func registerAppRefresh(
_ taskID: String,
handler: @escaping () async -> ()
) {
BGTaskScheduler.shared.register(
forTaskWithIdentifier: taskID,
using: nil
) { bgTask in
let task = Task {
await handler()
bgTask.setTaskCompleted(success: true)
}
bgTask.expirationHandler = {
task.cancel()
}
}
}
// use taskID and action from .backgroundTask(.appRefresh(taskID), action: action)
registerAppRefresh(<taskID>, action)
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags: