the launchHandler is there to tell you the task has started and provide you the BGTask object you use to manage that work. No task type actually requires the work to occur inside the task. Thanks Kevin! So I need to think about this a little differently then. Instead of performing the work once you get a BGContinuedProcessingTask, just begin performing the work (the exact same way you do in iOS 18), if a BGContinuedProcessingTask starts persist it and update it as the work completes, and reset state when the work finishes or gets canceled. Basically, something like this: 1-6 I put together code to demonstrate this approach. Did I understand correctly, this should be all good with this simple counting demo? class ViewController: UIViewController { private let taskIdentifier = (Bundle.main.bundleIdentifier!).count_task private let countToNumber: Int64 = 100 private var currentBackgroundContinuedProcessingTask: BGContinuedProcessingTask? private var shouldStopCounting = false @IBOutlet var progressLabel: UILabel
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags: