day-part-background
Schedule short tasks such as retrying a sync or refreshing cached data. Register handlers that can run independently of a page, then choose how long the schedule needs to survive.
| Scheduler | Lifetime | Platforms |
|---|---|---|
| Persistent | The OS retains requests after the app process exits. | iOS and Android |
| In-process | Pending jobs disappear when the process exits. | iOS, Android, macOS, Windows, and Linux |
Check capabilities() before choosing. Persistent scheduling never falls back to in-process
work. Web and HarmonyOS support neither scheduler.
Add to your app
Build with the Day CLI. Android uses WorkManager; iOS uses BGTaskScheduler and requires declared task identifiers and background modes.
Register and schedule a task
use ;
register_task!;
async
Handlers run on worker threads and must tolerate retries. Persist inputs before scheduling; a handler cannot depend on an open window or page signals. The OS chooses the execution time and may cancel or defer work. Keep a foreground path for actions users need immediately.
For work that only needs to run while the process stays alive, use in_process::schedule with
the same registered handler. It supports delays and retries but rejects network and charging
constraints. Cancellation is cooperative in both schedulers.
Documentation and examples
- Scheduling rules, cancellation, and platform setup
- Run Background Lab
- CI, crate reservation, and trusted publishing