# Background Tasks & App States

> What apps can and cannot do in the background on Android and iOS, and how to schedule sync, uploads and periodic work reliably. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/mobile/background-work
Last updated: 2026-11-28

What apps can and cannot do in the background on Android and iOS, and how to schedule sync, uploads and periodic work reliably.

Advanced · about 6 hours · difficulty 4/5

Learn first: [Offline-first & Data Synchronisation](https://www.internhack.in/roadmaps/tracks/mobile/offline-first)

Desktop programs can run whenever they like; mobile apps cannot. Both OSes aggressively limit background execution to save battery, and the rules differ.

### The rules in brief

- **iOS**: apps are suspended shortly after leaving the foreground. Allowed exceptions include background fetch/refresh (`BGAppRefreshTask`), processing tasks (`BGProcessingTask`, often while charging), background URL sessions for uploads/downloads, audio, location and VoIP. The system decides when scheduled tasks actually run.
- **Android**: Doze and app standby restrict background work. Use **WorkManager** for deferrable, guaranteed work with constraints (network, charging), and **foreground services** with a visible notification for user-visible ongoing tasks like navigation or music.

### Cross-platform tools

expo-background-task and expo-task-manager in React Native; workmanager in Flutter.

### Designing for it

- Assume background work may be delayed, batched or skipped; make it idempotent and resumable.
- Prefer server-driven approaches (silent push to trigger a sync, server-side processing) over polling.
- Sync when the app returns to the foreground as a reliable fallback.

### Pitfalls

Expecting a timer to fire every 15 minutes exactly on iOS. It will not.

**Good enough to move on:** your offline outbox syncs through a scheduled background task and also on app foreground.

## Key concepts

- **iOS background modes**
- **BGTaskScheduler**
- **Android Doze and app standby**
- **WorkManager**
- **Foreground services**
- **Background uploads and downloads**
- **Silent push to trigger sync**

## Mini project

Add a background sync task to your offline-first expense tracker and log each run with a timestamp to observe how often each OS actually runs it.

## Check yourself

Why can't you rely on a background task running at an exact interval on iOS, and what do you do instead?

## Free resources

- [Android: Background work with WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager) (Android Developers)
- [Apple Background Tasks](https://developer.apple.com/documentation/backgroundtasks) (Apple)
- [Expo BackgroundTask](https://docs.expo.dev/versions/latest/sdk/background-task/) (Expo)

Previous: [Sensors, Haptics & Biometrics](https://www.internhack.in/roadmaps/tracks/mobile/sensors-biometrics) · Next: [Animations & Transitions](https://www.internhack.in/roadmaps/tracks/mobile/animations)

## More in Device Capabilities & Background Work

- [Runtime Permissions & Privacy](https://www.internhack.in/roadmaps/tracks/mobile/permissions)
- [Camera, Photos & Media](https://www.internhack.in/roadmaps/tracks/mobile/camera-media)
- [Location & Maps](https://www.internhack.in/roadmaps/tracks/mobile/location-maps)
- [Sensors, Haptics & Biometrics](https://www.internhack.in/roadmaps/tracks/mobile/sensors-biometrics)
- [Background Tasks & App States](https://www.internhack.in/roadmaps/tracks/mobile/background-work)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Mobile App Developer Roadmap](https://www.internhack.in/roadmaps/tracks/mobile)
