Skip to content

@capgo/capacitor-background-task

Periodic background fetch tasks on iOS and Android.

Define module scope tasks, schedule intervals, and return results the OS understands for sync and cache warming.

PlatformSupportNotes
iOSYesBGTaskScheduler identifiers in Info.plist
AndroidYesWorkManager style jobs
WebNoUse service workers
  • defineTask - Register the JavaScript callback for a named task.
  • registerTaskAsync - Persist and schedule a periodic task.
  • unregisterTaskAsync - Cancel future runs for one task.
  • isTaskRegisteredAsync - Check whether a task is registered.
  • getRegisteredTasksAsync - List currently registered task names.
  • getPendingTaskRunsAsync - Inspect native task events recorded before JavaScript was ready.
  • getStatusAsync - Check native background task availability.
  • triggerTaskWorkerForTestingAsync - Run registered tasks immediately during development.
  • addExpirationListener - Handle iOS expiration callbacks.
  • define, schedule, cancel, statusAsync, and finish - Compatibility helpers for react-native-background-task.

Background tasks are not exact timers. Android and iOS decide when to run scheduled work based on battery, network, app usage, and system policy.

PlatformNative schedulerImportant behavior
AndroidWorkManagerPeriodic work has a 15-minute minimum interval.
iOSBGTaskSchedulerminimumInterval is an earliest begin date, not a guaranteed cadence.
WebTest-only fallbackNo real background scheduler is available.
MethodDescription
defineTaskDefines the JavaScript callback for a named task.
registerTaskAsyncRegisters a named periodic background task.
unregisterTaskAsyncCancels future task runs.
isTaskRegisteredAsyncReturns whether a task is registered.
getRegisteredTasksAsyncLists registered task names.
getPendingTaskRunsAsyncLists native task events waiting to be finished.
getStatusAsyncReturns whether native background scheduling is available.
triggerTaskWorkerForTestingAsyncTriggers registered tasks for development and QA.
addExpirationListenerListens for iOS expiration events.

This reference is synced from src/definitions.ts in capacitor-background-task.

Keep going from @capgo/capacitor-background-task

Section titled “Keep going from @capgo/capacitor-background-task”

If you are using @capgo/capacitor-background-task to plan native plugin work, connect it with Using @capgo/capacitor-background-task for the native capability in Using @capgo/capacitor-background-task, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, and Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives.