Skip to content

iOS - Task scheduled before it's registered #660

@MatteoMeil

Description

@MatteoMeil
  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.9.0+3
Xcode version 26.2
Swift version 6.2.3
iOS deployment target 26 (minimum 14)

Describe the error

On iOS, following Option A in Quick Start, and executing registerPeriodicTask from Flutter, causes the following error messages (visible by debugging though XCode):

com.yourapp.YOUR_TASK_NAME is not advertised in the application's Info.plist
Could not schedule BGAppRefreshTask The operation couldn’t be completed. (BGTaskSchedulerErrorDomain error 3.)

Adding BGTaskSchedulerPermittedIdentifiers to Info.plist causes, however, another error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No launch handler registered for task with identifier com.yourapp.YOUR_TASK_NAME'

In fact, task gets scheduled through BGTaskScheduler.shared.submit before it's actually registered through BGTaskScheduler.shared.register.

Workaround:

  1. Add BGTaskSchedulerPermittedIdentifiers to Info.plist and, in its array, add com.yourapp.YOUR_TASK_NAME
  2. Add the following to AppDelegate.swift (ref: Option C step 2)
import workmanager_apple 

WorkmanagerPlugin.registerPeriodicTask(
  withIdentifier: "com.yourapp.YOUR_TASK_NAME",
  frequency: NSNumber(value: 20 * 60) // duration in seconds, same of the one set via flutter
)

Output of flutter doctor

[✓] Flutter (Channel stable, 3.38.5, on macOS 15.7.3 24G419 darwin-arm64, locale
it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.2)
[✓] Chrome - develop for the web
[✓] Connected device (3 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions