BackgroundTaskManager
Constructed-instance entry point — held by the user's app graph for the app's lifetime.
Three things hang off the instance:
scheduling verbs (schedule, cancel, cancelAll, scheduled, guarantees): the scheduling surface, promoted directly onto the instance. There is no separate
Schedulerobject to hold — pass theBackgroundTaskManagerinstance itself down the app graph.register: associate a task id with a factory closure that builds a fresh
BackgroundWorkerper dispatch.start: finalize init (seals the registry; iOS/macOS run the ephemeral sweep + register OS handlers + resurrect periodic schedules; Android flips the not-ready backstop). Idempotent.
shutdown: tear down library-owned coroutine scopes (iOS / macOS). Android is a no-op. Safe to call repeatedly.
Construct via the per-platform extension factory:
androidMain: BackgroundTaskManager.Companion.create taking anApplication.iosMain: BackgroundTaskManager.Companion.create (no required args).macosMain: BackgroundTaskManager.Companion.create (no required args).jvmMain: BackgroundTaskManager.Companion.create (no required args).
@OptIn(ExperimentalObjCName::class): standard SKIE annotation; stable in practice and required for boundary refinement (CLAUDE.md §8).
Types
Companion object exists so per-platform source sets can install extension entry points: BackgroundTaskManager.shared (commonMain), BackgroundTaskManager.configure(application) (Android), and BackgroundTaskManager.create(...) (iOS / macOS / JVM). commonMain cannot define the constructors itself because the Android variant requires an Application and the Apple variants don't — there's no common signature that doesn't leak Any?.
Functions
The WorkerFactory to install in your WorkManager.Configuration. Compose with DelegatingWorkerFactory if you also use Hilt's HiltWorkerFactory or any other custom factory.
Cancel every pending scheduled request the library knows about.
Snapshot of environment and configuration issues the library has detected — missing iOS Info.plist entries, disabled Android WorkManager, registry not yet sealed, etc. An empty PlatformDiagnostics.diagnostics list (or PlatformDiagnostics.isHealthy == true) means the library believes the environment is correctly configured.
Hot stream of MonitorEvents — every schedule, dispatch, deferral, completion, retry, cancellation, and library-internal error the scheduler observes.
What this platform's scheduler actually guarantees.
Register a BackgroundWorkerFactory that owns many task ids at once. Must be called before start. Throws if start has already run, or any of the factory's BackgroundWorkerFactory.taskIds collide with an existing per-id registration or another factory.
Register a BackgroundWorker factory for taskId. Must be called before start. Throws if start has already run or taskId is already registered.
Inspector view of every registered factory — one FactoryDescriptor per closure registration and per BackgroundWorkerFactory object. See WorkerRegistry.factoryDescriptors for ordering.
Every task id currently registered with the library — the union of per-id closures and every BackgroundWorkerFactory's declared ids.
Schedule a WorkRequest. If a request with the same WorkRequest.taskId is already pending, policy decides what happens.
Snapshot of currently-scheduled (pending or running) tasks the library knows about. Best-effort per platform.