Configuring background execution modes
Indicate the background services your app requires to continue executing in the background in iOS, iPadOS, tvOS, visionOS, and watchOS.
Overview
Typically, an app is in a suspended state when it’s in the background. However, there are a limited number of background execution modes your app can support that enable it to run when in the background, such as playing audio, receiving location updates, or processing scheduled tasks. For apps that adopt one or more of these modes, the system launches or resumes the app, in the background, and affords it time to process any related events.
Use background execution modes sparingly because overuse can negatively impact device performance and battery life. If an alternative to executing in the background exists, use the alternative instead. For example, apps can use the significant-change location service to receive location events as an alternative to using the Location updates background mode.
Before you can select the background execution modes your app requires, follow the steps in Add a capability to add the Background Modes capability to your app’s target.
[Image]
The background execution modes that appear after you add the capability depend on the target’s platform. For watchOS apps with separate WatchKit extensions, you need to add the capability to the WatchKit Extension target.
Specify the background modes your app requires
Before your app can leverage one or more background execution modes, you need to declare the modes it requires by performing the following:
Select your project in Xcode’s Project navigator.
Select the app’s target in the Targets list.
Click the Signing & Capabilities tab in the project editor.
Find the Background Modes capability.
Select one or more background execution modes using the corresponding checkboxes.
For watchOS apps, choose the appropriate session type from the pop-up menu. For more information, see Using extended runtime sessions.
[Image]
Xcode adds the UIBackgroundModes array to your app’s Info.plist file, if it isn’t already present, and uses the modes you select to populate the array with the necessary values.
Apple’s platforms support these background execution modes:
Mode | Value | Description | Platforms |
|---|---|---|---|
Audio, AirPlay, and Picture in Picture |
| The app plays audible content in the background. For more information, see Configuring Your App For Media Playback. | iOS, iPadOS, tvOS, visionOS |
Audio |
| The app plays audible content in the background. For more information, see Playing Background Audio. | watchOS |
Location updates |
| The app provides location-based information and requires the use of the platform’s standard location service. For more information, see Configuring Your App To Use Location Services. | iOS, iPadOS, watchOS |
Voice over IP |
| The app provides Voice over IP services. For more information, see the Callkit framework. | iOS, iPadOS, visionOS, watchOS |
External accessory communication |
| The app communicates with an accessory that delivers data at regular intervals. For more information, see the Externalaccessory framework. | iOS, iPadOS |
Uses Bluetooth LE accessories |
| The app communicates with a Bluetooth accessory while in the background. For more information, see the Corebluetooth framework. | iOS, iPadOS, visionOS |
Acts as a Bluetooth LE accessory |
| The app uses peripheral mode to communicate with a Bluetooth accessory. For more information, see the Corebluetooth framework. | iOS, iPadOS |
Background fetch |
| The app requires new content from the network at regular intervals. For more information, see Using Background Tasks To Update Your App. | iOS, iPadOS, tvOS, visionOS |
Remote notifications |
| The app uses push notifications as a signal that new content is available to download. For more information, see Pushing Background Updates To Your App. | iOS, iPadOS, tvOS, visionOS, watchOS |
Background processing |
| The app executes scheduled tasks while in the background. For more information, see Bgtaskscheduler. | iOS, iPadOS, tvOS, visionOS |
Workout processing |
| The app uses a workout session to track a user’s activity on Apple Watch. For more information, see Running Workout Sessions. | watchOS |
Uses Nearby Interaction |
| The app locates and interacts with nearby devices. For more information, see the Nearbyinteraction framework. | iOS, iPadOS |
Push to Talk |
| The app launches in response to a push notification and plays audible content in the background. For more information, see the Pushtotalk framework. | iOS, iPadOS |