AFGeofenceBackgroundTaskManager

Manages iOS BackgroundTasks for geofencing heartbeats.

  • Registers a single BGAppRefresh task handler.

  • Schedules (or reschedules) the task with a sane minimum delay (≥15 minutes recommended by Apple).

  • Handles expiration safely and always completes the task.

Notes: • Ensure TASK_ID is present in Info.plist under BGTaskSchedulerPermittedIdentifiers. • System controls exact execution time; earliestBeginDate is only a hint. • Keep your operation short; the system may terminate long-running work.

Functions

Link copied to clipboard
fun cancel()

Cancel all pending requests for this task id.

Link copied to clipboard
fun register()

Register the task handler (call once, e.g., in AppDelegate.didFinishLaunching).

Link copied to clipboard
fun schedule(minDelayMinutes: Int = 15, replaceExisting: Boolean = true)

Schedule (or reschedule) the app refresh task.