I regularly see questions, both here on the Apple Developer Forums and in my Day Job™ at DTS, that are caused by a fundamental misunderstanding of how background execution works on iOS. These come in many different variants, for example:
How do I keep my app running continuously in the background?
If I schedule a timer, how do I get it to fire when the screen is locked?
How do I run code in the background every 15 minutes?
How do I set up a network server that runs in the background?
How can my app provide an IPC service to another one of my apps while it’s in the background?
How can I resume my app in the background if it’s been ‘force quit’ by the user?
The short answer to all of these is You can’t. iOS puts strict limits on background execution. Its default behaviour is to suspend your app shortly after the user has moved it to the background; this suspension prevents the process from running any code.
There’s no general-purpose mechanism for:
Running code continuously in the background
Running code at some specific time in the background
Running code periodically at a guaranteed interval
Resuming in the background in response to a network or IPC request [1]
However, iOS does provide a wide range of special-purpose mechanisms for accomplishing specific user goals. For example:
If you’re building a music player, use the audio background mode to continue playing after the user has moved your app to the background.
If you’re building a timer app, check out the AlarmKit framework. On older systems, use a local notification to notify the user when your timer has expired.
If you’re building a video player app, use AVFoundation’s download support.
Keep in mind that the above is just a short list of examples. There are many other special-purpose background execution mechanisms, so you should search the documentation for something appropriate to your needs.
IMPORTANT Each of these mechanisms fulfils a specific purpose. Do not attempt to use them for some other purpose. Before using a background API, read clause 2.5.4 of the App Review Guidelines.
Additionally, iOS provides some general-purpose mechanisms for background execution:
To resume your app in the background in response to an event on your server, use a background notification (aka a ‘silent’ push). For more information, see Pushing background updates to your App.
To request a small amount of background execution time to refresh your UI, use the BGAppRefreshTaskRequest class.
To request extended background execution time, typically delivered overnight when the user is asleep, use the BGProcessingTaskRequest class.
To continue user-visible work after the user has left your app, use the BGContinuedProcessingTask class.
To prevent your app from being suspended for a short period of time so that you can complete some user task, use a UIApplication background task. For more information on this, see UIApplication Background Task Notes.
To download or upload a large HTTP resource, use an URLSession background session.
All of these mechanisms prevent you from abusing them to run arbitrary code in the background. As an example, consider the URLSession resume rate limiter.
For more information about these limitations, and background execution in general, I strongly recommend that you watch WWDC 2020 Session 10063 Background execution demystified [2]. It’s an excellent resource.
Specifically, this talk addresses a common misconception about the app refresh mechanism (BGAppRefreshTaskRequest and the older background fetch API). Folks assume that app refresh will provide regular background execution time. That’s not the case. The system applies a range of heuristics to decide which apps get app refresh time and when. This is a complex issue, one that I’m not going to try to summarise here, but the take-home message is that, if you expect that the app refresh mechanism will grant you background execution time, say, every 15 minutes, you’ll be disappointed. In fact, there are common scenarios where it won’t grant you any background execution time at all! Watch the talk for the details.
[1] iOS 26 introduced support for general-purpose IPC, in the form of enhanced security helper extensions. However, these can only be invoked by the container app, and that means there’s no background execution benefit.
[2] Sadly the video is currently not available from Apple. I’ve left the link in place just in case it comes back.
When the user ‘force quits’ an app by swiping up in the multitasking UI, iOS interprets that to mean that the user doesn’t want the app running at all. So:
If the app is running, iOS terminates it.
iOS also sets a flag that prevents the app from being launched in the background. That flag gets cleared when the user next launches the app manually.
This gesture is a clear statement of user intent; there’s no documented way for your app to override the user’s choice.
Note In some circumstances iOS will not honour this flag. The exact cases where this happens are not documented and have changed over time.
Finally, if you have questions about background execution that aren’t covered by the resources listed here, please open a new thread on the forums with the details. Put it in a reasonable subtopic and tag it appropriately for the technology you’re using; if nothing specific springs to mind, use Background Tasks. Also, make sure to include details about the specific problem you’re trying to solve because, when it comes to background execution, the devil really is in the details.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Change history:
2026-01-09 Added a reference to AlarmKit. Added a reference to BGContinuedProcessingTask. Add a footnote about IPC and another one about WWDC 2020 Session 10063. Made other minor editorial changes.
2024-03-21 Added a discussion of ‘force quit’.
2023-05-11 Added a paragraph that explains a common misconception about the app refresh mechanism. Made other minor editorial changes.
2021-08-12 Added more entries to the common questions list, this time related to networking and IPC. Made minor editorial changes.
2021-07-26 Extended the statement about what’s not possible to include “running code periodically at a guaranteed interval”.
2021-07-22 First posted.
Overview
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Guideline 3.2.1 - Business - Other Business Model Issues - Acceptable
The
seller and company names associated with your app do not reflect the
financial institute name "Payments" in the app or its metadata, as
required by Guideline 3.2.1(viii) of the App Store Review Guidelines.
How can I solve this issue?
Where will I find Seller Name and Company Name?
Do I required to provide same company/organization name as app name?
Can anybody provide me steps about how to solve this issue?
For now I am using individual account. Do I need to change it to organization account?
Since WatchOS 8.0.1 CoreBluetooth drops an active connection if the App goes to background (or back to foreground).
This can be reproduced easily with this sample code:
Interacting with Bluetooth Peripherals During Background App Refresh
If you run the app on the Apple Watch and turn your wrist, an active connection is terminated.
In the output window you can read:
2021-10-20 20:22:41.210839+0200 BARBluetooth WatchKit Extension[382:94603] [BluetoothReceiver] disconnected from Sender.
The same is the case with my other Watch Apps, that are connecting to BLE devices.
As far as I remember, with WatchOS 8.0 everything was fine.
Since this occurs even on WWDC21 sample code this must be a bug.
Is there a way to fix it for myself, or do I have to wait until it gets fixed by Apple?
I've encountered an issue where we need multiple domain associations with separate Apple Pay implementations.
Briefly, we have a /.well-known/apple-developer-merchantid-domain-association already setup with Stripe, and now we need another, different version of the file to get setup with FreedomPay. FreedomPay insists this file represents a three-way relationship between all parties and I have no reason to disbelieve them.
I'm wondering if anyone has encountered this or if there is a standard procedure. I'm currently trying to find documentation on the exact way Apple Pay verification interacts with this file to see if we can produce it dynamically.
Our app will launch automatically in the background,Doubt is the result of background fetch ,so we cancel the background modes setting of the background fetch,but we still can see the performFetchWithCompletionHandler method called when app launch in the background。Background launch will cause some bugs in our app. We don't want the app to start in the background. We hope to get help
Hi! I'm trying to figure out what mechanism request stop sends to the guest to actually request a stop. It doesn't appear that Virtualization.framework implements any ACPI bits relating to power buttons, so unclear how a linux VM would detect that a request has been stopped. I don't see any documentation around what devices are implemented by Virtualization.framework either, in terms of things like realtime clock, etc.
Thanks for any help!
I'm working on a FileProvider which allows access to encrypted files in Dropbox; I can successfully read and present the decrypted files, so I know it's basically working. But I'm having problems getting FileProvider to re-enumerate a folder when its encryption status changes.
When the FileProvider receives an update notification saying a folder is now encrypted, I use signalEnumerator to re-enumerate the folder:
FileProviderExtension.manager?.signalEnumerator(for: existingItem.itemIdentifier, completionHandler: { (ourError : Error?) -> Void in
if let ourError = ourError {
log("notifyCallback: mount / unmount failed re-enumeration: \(ourError)")
} else {
log("notifyCallback: mount / unmount signalled re-enumeration; pending")
}
})
The log reports that the re-enumeration is pending... but as far as I can tell, neither enumerateItems nor enumerateChanges is called on the folder's item unless a Finder window is actually open for that folder. This means that, when an app other than Finder tries to access the files through the filesystem, it doesn't see the updated set of filenames.
(For further reference: I've added code to both enumerateItems and enumerateChanges, so that if the call has been triggered by a recent folder-encryption notification, it retrieves a complete set of items from the Dropbox folder. If a retrieved file has an encrypted filename, it reports it as a modified item and returns its filename in-clear; if the filename isn't encrypted, it doesn't return the item (for enumerateItems) or returns it as a deleted item (for enumerateChanges). This approach seems to work successfully for listing folders with a constant state; it's only if the user encrypts / decrypts a folder without currently having a Finder window open inside that folder that I'm not seeing a refresh.)
Any advice on how I can force a re-enumeration without a Finder window currently being displayed?
General:
Forums subtopic: App & System Services > Networking
DevForums tag: Network Extension
Network Extension framework documentation
Routing your VPN network traffic article
Filtering traffic by URL sample code
Filtering Network Traffic sample code
TN3120 Expected use cases for Network Extension packet tunnel providers technote
TN3134 Network Extension provider deployment technote
TN3165 Packet Filter is not API technote
Network Extension and VPN Glossary forums post
Debugging a Network Extension Provider forums post
Exporting a Developer ID Network Extension forums post
Network Extension Framework Entitlements forums post
Network Extension vs ad hoc techniques on macOS forums post
Network Extension Provider Packaging forums post
NWEndpoint History and Advice forums post
Extra-ordinary Networking forums post
Wi-Fi management:
Wi-Fi Fundamentals forums post
TN3111 iOS Wi-Fi API overview technote
How to modernize your captive network developer news post
iOS Network Signal Strength forums post
See also Networking Resources.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
General:
Forums topic: Code Signing
Forums subtopics: Code Signing > General, Code Signing > Certificates, Identifiers & Profiles, Code Signing > Notarization, Code Signing > Entitlements
Forums tags: Code Signing, Signing Certificates, Provisioning Profiles, Entitlements
Developer Account Help — This document is good in general but, in particular, the Reference section is chock-full of useful information, including the names and purposes of all certificate types issued by Apple Developer web site, tables of which capabilities are supported by which distribution models on iOS and macOS, and information on how to use managed capabilities.
Developer > Support > Certificates covers some important policy issues
Bundle Resources > Entitlements documentation
TN3125 Inside Code Signing: Provisioning Profiles — This includes links to the other technotes in the Inside Code Signing series.
WWDC 2021 Session 10204 Distribute apps in Xcode with cloud signing
Certificate Signing Requests Explained forums post
--deep Considered Harmful forums post
Don’t Run App Store Distribution-Signed Code forums post
Resolving errSecInternalComponent errors during code signing forums post
Finding a Capability’s Distribution Restrictions forums post
Signing code with a hardware-based code-signing identity forums post
New Capabilities Request Tab in Certificates, Identifiers & Profiles forums post
Isolating Code Signing Problems from Build Problems forums post
Investigating Third-Party IDE Code-Signing Problems forums post
Determining if an entitlement is real forums post
Code Signing Identifiers Explained forums post
Mac code signing:
Forums tag: Developer ID
Creating distribution-signed code for macOS documentation
Packaging Mac software for distribution documentation
Placing Content in a Bundle documentation
Embedding nonstandard code structures in a bundle documentation
Embedding a command-line tool in a sandboxed app documentation
Signing a daemon with a restricted entitlement documentation
Defining launch environment and library constraints documentation
WWDC 2023 Session 10266 Protect your Mac app with environment constraints
TN2206 macOS Code Signing In Depth archived technote — This doc has mostly been replaced by the other resources linked to here but it still contains a few unique tidbits and it’s a great historical reference.
Manual Code Signing Example forums post
The Care and Feeding of Developer ID forums post
TestFlight, Provisioning Profiles, and the Mac App Store forums post
For problems with notarisation, see Notarisation Resources. For problems with the trusted execution system, including Gatekeeper, see Trusted Execution Resources.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Topic:
Code Signing
SubTopic:
General
Tags:
Entitlements
Provisioning Profiles
Signing Certificates
Code Signing
Issue Description:
Apps that support both iOS and tvOS can have different versions in App Store for each type(iOS and tvOS) but same Bundle Identifier and iTunesStoreID/trackID.
For example,
the iOS version of YouTube has the latest version in App Store as 17.30.3
the tvOS version of YouTube has the latest version in App Store as 2.07.01
This can be verified from two by two specific iTunes look Up API as shown below
https://itunes.apple.com/lookup?id=544007664
https://itunes.apple.com/lookup?id=544007664&entity=tvSoftware
Sample contentMetadataLookup URL: https://uclient-api.itunes.apple.com/WebObjects/MZStorePlatform.woa/wa/lookup?version=2&id=544007664&p=mdm-lockup&caller=MDM&platform=enterprisestore&cc=us&l=en
Queries:
What should we do to get the tvOS specific version of an app in contentMetadataLookup URL?
The trackViewURL doesn't show tvOS specific version history of the app - https://apps.apple.com/us/app/youtube-watch-listen-stream/id544007664?platform=appleTV . How should we view this the apps' tvOS specific version history?
Kindly help us with the queries.
Topic:
App Store Distribution & Marketing
SubTopic:
General
Tags:
App Store
Apple Business Manager
Business and Enterprise
Device Management
Hi there,
I dont now what to do anymore and you help is more than appreciated.
My app + subscriptions has been certified before 8 days on Monday, 8th but my subscriptions are not shown in the App Store. That leads to a loading spinner since 8 days in my production app!
I have an email, where I see that the app + all 6 subscriptions has been approved.
On the other hand I see that my subscriptions are still in review and dont see them below the app in the App Store.
I was given last week on Tuesday (before 7 days) an expedite review for the subscriptions, because the Apple developer support was writing that the subscriptions are not yet certified.
The expedite review has not taken place since 7 days or its not true what the Apple Developer Support is writing (subscriptions need to be reviewed).
I think the subscriptions are not linked to the app and I am in a dead lock situation. I need your help, because I have fears that I receive 1 star recommendations and the developer support cannot help me since 8 days.
Best regards
Tino
Link to the App:
https://apps.apple.com/de/app/vario-one/id1605797423
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Review
App Store Connect
Subscriptions
Show dialog content "Unable to find a team with the given Team ID 'R6A82WMBSC' to which you belong. Please contact Apple Developer Program Support. https://developer.apple.com/support" when open "https://developer.apple.com/account/resources"
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
I have installed the latest beta on my iPad , iPadOS 16.1 (20B5050f)
On running in app in Playgrounds that has a TextField, external keyboard input do not seem to be working.
Tapping on the Text field inserts the cursor but no text can be entered on my external keyboard.
(TextEditor field also do not work)
Tested with both a Smart Keyboard and a Magic Keyboard.
The keyboard works to enter the code in playgrounds, so it is not a keyboard connection issue.
Disconnecting the keyboard, the onscreen keyboard is displayed and works correctly.
Is this a Playgrounds issue or an iPadOS 16.1 issue or a compatibility issue with Playgrounds & iPadOS 16.1 ?
import SwiftUI
struct ContentView: View {
@State var field: String = "Test input"
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
TextField("", text: $field)
.frame(height: 100)
}
}
}
I am developing CarPlay addition on our app. Which is distributed with the Enterprise In distribution method, so we do not have a product in the App Store. I am wondering if CarPlay support can be provided in applications distributed with the Enterprise in distribution method?
If this is not possible, I will inform management that this is not possible.
I am waiting for your answers, thanks.
Topic:
Developer Tools & Services
SubTopic:
General
Tags:
Enterprise
Entitlements
CarPlay
wwdc2022-10016
We have developed a Parental/Self control app using Screen time API.
We have used individual authentication to authorize the app, using the instructions here:
https://developer.apple.com/documentation/familycontrols/authorizationcenter
The problem is , that individual auth can be disabled easily , by the following steps:
enter Settings app.
in Settings app, click on the Parental/Self control app.
click to disable screen time restriction.
show the device owner's face/fingerprint. (or pin code)
Why is that a problem:
Parental control apps, or self-control apps, are about giving control to the software, To make it hard for the user to disable the restrictions.
So using the flow I have introduced above, it's super-easy for a user to disable his Parental control restrictions, which misses the entire point of Parental/Self control idea.
Furthermore, not only the user have the means to unlock his screen time restrictions, he also MUST have the means to unlock it.
This makes Screen time (with individual auth) useless:
I have a code ready to make a great parental control app for my clients, with amazing ideas, but I can't use the Screen time API unless this problem is fixed.
Why child-parent auth is not enough:
My clients are grownups people between ages of 15-40, that are interested in self-control, so they don't have iCloud child accounts.
also, the child-parent auth solution forces my clients to give some control to other person, and my clients prefer their privacy. Some of them prefer self-control and not parental-control.
What I suggest as a solution:
1: Give more options to users how to disable the Screen time restrictions. including:
a second faceID / FingerPrint (that isn't the same as the one used to unlock the device)
a second pin password.
a string password
2: Give the users the option to choose to not have the device's owner Face/Finger/Pincode ID , as a method to disable the Screen time restrictions.
In the verifyReceipt API response, there is a "is_trial_period" field.
As detailed in WWDC 2023 the verifyReceipt is deprecated, how to fetch the fact that the subscription is during the free trial period via recommended App Store server APIs?
Topic:
App Store Distribution & Marketing
SubTopic:
General
Tags:
App Store Server API
wwdc2023-10141
I'm trying to put a sub menu inside the context menu using the NSExtensionFileProviderActions in info.plist. Which should look like this image below
I have been trying to use FPUIActionExtensionViewController for doing this task but I havent got any context menu like above. But still doing that does seem to complicate the task more.
Is there a simpler way to do this task, like doing it within the info.plist so I dont have to complicate the task by creating a view controller. ?
Hello Everyone,
I'm trying to add badges to files in my File Provider Extension for macOS. I'm not trying to create my own Item decorations here, but use the default Icons provided by apple (such as com.apple.icon-decoration.badge.heart , com.apple.icon-decoration.badge.pinned). I've gone through the Sample code provided by Apple for Fruit Basket.
I've tried to replicate the same thing in my Extension as well but It seems I'm unable to display Icons. I'm not even getting any Error when the Icons are not being displayed, So I've been stuck for a month on this.
These are the Things that I've done below:
Folder Structure :
FileExplorer
|- FileProviderApp
| |- UI.swift
| |- ContentView.swift
|- Extension
|- extension.swift
|- item.swift
|- enumerator.swift
|- info.plist
According to the instructions given in the Documentation for Decorations here : https://developer.apple.com/documentation/fileprovider/nsfileprovideritemdecorating.
The implementation was done as follows:
content inside info.plist of the File provider Extension
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.fileprovider-nonui</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).FileProviderExtension</string>
<key>NSFileProviderDecorations</key>
<array>
<dict>
<key>BadgeImageType</key>
<string>com.apple.icon-decoration.badge.heart</string>
<key>Category</key>
<string>Badge</string>
<key>Identifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).heart</string>
<key>Label</key>
<string>Heart Item</string>
</dict>
</array>
</dict>
</dict>
</plist>
In my extension's NSFileProviderItem I've also Implemented the protocol NSFileProviderItemDecorating. and the decoration's method as
static let decorationPrefix = Bundle.main.bundleIdentifier!
static let heartDecoration = NSFileProviderItemDecorationIdentifier(rawValue: "\(decorationPrefix).heart")
var decorations: [NSFileProviderItemDecorationIdentifier]?
{
var decos = [NSFileProviderItemDecorationIdentifier]()
decos.append(Item.heartDecoration)
return decos
}
I was expecting to see badges on the File items in Finder, but i got nothing. When I modified the FruitBasket Project to do the same i was able to see badges, but not when I try to implement it in my Extension.
Was I missing a step or is the issue something else ?
I am developing a FileProvider extension which will be launched for one or more domains. In the case where I have two domains, say with displayNames "Foo" and "Bar", the finder will then show "MyExtension - Foo" and "MyExtension - Bar" respectively after registering them with addDomain.
However, if I only have a single domain, let's say "Foo" – then I just see "MyExtension" rather than "MyExtension - Foo". Now ideally I'd like to be able to control the entire name, but barring that at least be able to show the displayName even with a single domain. How can I achieve that?
Hi,
We applied for Tap to Pay on iPhone entitlement and were approved, but on distribution support it's only showing Development.
We can build and debug Tap to Pay on development, but unable to build release.
We opened ticket with Apple support but they were saying it was configured correctly. I attached screenshot of our developer account entitlement for Tap to Pay. It clearly said Development only.