Even in a very simple UIKit test project, I'm not able to get BGContinuedProcessingTask (new in iOS 26) to do anything.

But using essentially the same code in a SwiftUI project, it works fine.

So my question is: has anyone been able to work out a way of getting BGContinuedProcessingTask to work in a UIKit project?

The example code here is based on https://github.com/infinitepower18/BGContinuedProcessingTaskDemo — I'm doing exactly what that code does, and indeed that code works fine on my device, but when I put the same code into a UIKit project, the task never runs. (You should assume that I've set up my Info.Plist and capabilities correctly; that's not the issue.)

import UIKit import BackgroundTasks import SwiftUI class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() register() } var registeredCleanupTask = false /// Registers the background continued processing task with the system. private func register() { if registeredCleanupTask { return } registeredCleanupTask = true BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.neuburg.matt.test.cleanup2", using: nil) { task in guard let task = task as? BGContinuedProcessingTask else { return } var wasExpired = false task.expirationHandler = { wasExpired = true } task.progress.totalUnitCount = 100 task.progress.completedUnitCount = 0 while (task.progress.completedUnitCount < task.progress.totalUnitCount) && !wasExpired && !task.progress.isFinished { sleep(1) task.progress.completedUnitCount += 1 task.updateTitle("Title", subtitle: "\(task.progress.completedUnitCount)% complete") } task.setTaskCompleted(success: true) } } /// Runs the background continued processing task. private func runTask() { let request = BGContinuedProcessingTaskRequest( identifier: "com.neuburg.matt.test.cleanup2", title: "Title", subtitle: "Running..." ) request.strategy = .queue do { try BGTaskScheduler.shared.submit(request) } catch { print(error) } } @IBAction func doButton(_ sender: Any) { runTask() } }

matt's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.