BGTaskScheduler lets an iOS app do work in the background, refreshing content or running deferred processing when the system decides to grant time, without the user actively using the app. That convenience carries security considerations that are easy to overlook precisely because no one is watching. Work that runs in the background is still your app handling data, making network calls, and writing storage, so it needs the same security as foreground work, and there is a specific subtlety: the device may be locked while a background task runs, which interacts with file data protection. Here is what background tasks involve and how to handle them securely.
Short answer
BGTaskScheduler schedules background work on iOS, app refresh and longer processing tasks, that runs when the system grants time, without the user in the app. Per Apple, the security points are that background work is still your app doing sensitive things, so it must keep the same security as foreground, secure storage, TLS, and no bypassing of authentication or authorization just because there is no UI, and that the device may be locked while a task runs, which interacts with file data protection: do not downgrade the protection level of sensitive files to make them accessible while locked. Treat background execution as your app acting on the user's behalf unattended, maintaining your full security posture rather than relaxing it because no one is watching.
What you should know
BGTaskSchedulerruns background work: refresh and processing tasks.- It runs without the user in the app: when the system grants time.
- Background work is still sensitive: keep the same security as foreground.
- Do not bypass auth because there is no UI: server-side rules still apply.
- The device may be locked during a task: which affects data protection.
What is BGTaskScheduler, and what is the security angle?
It is the API for scheduling deferred and periodic background work, and the angle is that unattended work still needs full security. With BGTaskScheduler, you register tasks, an app-refresh task to update content, a processing task for longer or deferrable work, and the system runs them at times it chooses, often when the device is idle or charging, so your code executes without the user actively in the app. The security angle follows from that: background execution is still your app fetching data over the network, processing it, and writing to storage, just without a user present, so all the protections you apply in the foreground, encrypted transport, secure storage, careful data handling, must hold in the background too. It is easy to treat background code as somehow lower-stakes because there is no UI, but a network call or a file write in the background is exactly as security-relevant as one in the foreground. So the security angle is not a new class of vulnerability but the requirement to maintain your full posture in code paths that run unattended.
What are the considerations for background work?
A few that stem from running unattended and possibly while locked. The table lists them.
| Consideration | Detail |
|---|---|
| Same transport security | Background network calls still need TLS |
| Same storage security | Data written in the background needs secure storage |
| No auth bypass | Do not skip authentication or authorization without UI |
| Device may be locked | A task can run while the device is locked |
| Data protection class | Do not downgrade protection to access files while locked |
The recurring theme is that background tasks must not become a place where security is quietly relaxed. Network calls made in a background task need the same TLS and validation as foreground ones, and data fetched or produced needs the same secure storage. Crucially, do not let background execution bypass authentication or authorization, an operation that should require the user to be authenticated, or that the server gates, should not silently proceed in the background just because there is no UI to prompt; the server-side rules still apply. The locked-device point is specific to iOS: a background task may run while the device is locked, and iOS file data protection can make files with the strongest protection inaccessible while locked, so a tempting but wrong fix is to downgrade a sensitive file's protection class so the background task can read it while locked, which weakens protection for that sensitive data. Handle that case correctly instead of lowering protection.
How do you handle background tasks securely?
Maintain your full security posture in background code, and handle the locked case carefully. Apply the same transport and storage security in background tasks as in the foreground: use TLS for network calls, store any data securely in the Keychain or encrypted storage, and validate inputs, treating background code paths as first-class for security rather than an afterthought. Do not bypass authentication or authorization in the background; if an operation requires the user to be authenticated or is gated server-side, enforce that rather than letting it run unattended, and design background work so it does only what is safe to do without the user present. For the locked-device interaction, choose file data protection classes based on the data's sensitivity, not on background convenience, and if a background task genuinely needs to write data while the device is locked, structure it so sensitive data is not exposed by a weakened protection class, for example by deferring sensitive writes or using protection appropriate to the data rather than downgrading it. Keep background-fetched content that feeds a widget or Live Activity non-sensitive, since those surfaces are visible. The principle is that the background is just your app running unattended, so it carries the same security obligations, and the only new wrinkle, the locked device, should be handled without lowering protection on sensitive data.
What to watch out for
The first trap is treating background code as lower-stakes, skipping TLS, secure storage, or validation because there is no UI; apply the same security as foreground. The second is bypassing authentication or authorization in the background for an operation that should require the user or a server check. The third is downgrading a file's data protection class so a background task can read sensitive data while the device is locked, which weakens that data's protection. Background behavior is in your app code, so a pre-submission scan such as PTKD.com (https://ptkd.com), which reads the compiled IPA against OWASP MASVS, assesses your transport, storage, and data-protection handling, which applies to background code paths too, while the background task logic is yours to implement.
What to take away
BGTaskSchedulerruns background work without the user in the app, and that work is still your app handling data, so it needs the same security as foreground, TLS, secure storage, and no bypassing of authentication or authorization.- Do not relax security because there is no UI, and design background tasks to do only what is safe to do unattended, with server-side rules still enforced.
- The device may be locked during a background task, so choose file data protection classes by sensitivity and do not downgrade protection on sensitive data just to access it while locked.
- Use a pre-submission scan such as PTKD.com to assess your transport, storage, and data-protection handling, which covers background code paths as well as foreground.

