How do I get background runtime?

Asked on 06/21/2025

1 search

To get background runtime for your app, you can utilize various APIs provided by iOS, each designed for specific types of tasks. Here are some key points from the session "Finish tasks in the background" at WWDC 2025:

  1. Understanding Background Runtime: Background execution is not guaranteed; it's opportunistic and managed by the system to protect battery life and optimize performance. It's important to design your tasks to work with the system's constraints and priorities.

  2. APIs for Background Tasks: iOS provides several APIs to request background runtime. These include:

    • BGAppRefreshTask: Used for tasks like fetching content from servers before the app is used.
    • BGProcessingTask: Suitable for tasks like running ML models or handling database maintenance. It allows tasks to run when the device is on a charger and connected to a network to minimize battery impact.
    • Begin and End Background Task APIs: These allow your app to finish crucial work that should not be interrupted, such as cleaning up file handles or closing database connections.
  3. Designing Efficient Background Tasks: It's crucial to keep your background tasks efficient, minimal, and adaptive to system conditions. Tasks should be atomic and lightweight, and you should consider deferring non-urgent tasks until the device is charging.

For more detailed information, you can refer to the session Finish tasks in the background (07:29) which covers background task APIs.

Finish tasks in the background

Finish tasks in the background

Discover background execution advancements and understand how the system schedules runtime. We’ll discuss how to get the most out of background runtime to allow your app to deliver features in the background while maintaining a great foreground experience. We’ll also cover how APIs provide background runtime for your app, and how each API is tailored for different use cases — including new APIs in iOS and iPadOS 26 that let your app finish tasks as your app transitions from the foreground to the background.

Code-along: Elevate an app with Swift concurrency

Code-along: Elevate an app with Swift concurrency

Learn how to optimize your app’s user experience with Swift concurrency as we update an existing sample app. We’ll start with a main-actor app, then gradually introduce asynchronous code as we need to. We’ll use tasks to optimize code running on the main actor, and discover how to parallelize code by offloading work to the background. We’ll explore what data-race safety provides, and work through interpreting and fixing data-race safety errors. Finally, we’ll show how you can make the most out of structured concurrency in the context of an app.

Embracing Swift concurrency

Embracing Swift concurrency

Join us to learn the core Swift concurrency concepts. Concurrency helps you improve app responsiveness and performance, and Swift is designed to make asynchronous and concurrent code easier to write correctly. We’ll cover the steps you need to take an app through from single-threaded to concurrent. We’ll also help you determine how and when to make the best use of Swift concurrency features – whether it’s making your code more asynchronous, moving it to the background, or sharing data across concurrent tasks.