Skip to content

fix(ios): pass taskName to callback and honor initialDelay for one-off tasks - #687

Merged
ened merged 1 commit into
mainfrom
fix/670-661-ios-oneoff-taskname-and-delay
Aug 1, 2026
Merged

fix(ios): pass taskName to callback and honor initialDelay for one-off tasks#687
ened merged 1 commit into
mainfrom
fix/670-661-ios-oneoff-taskname-and-delay

Conversation

@ened

@ened ened commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

What changed

Two related iOS one-off task bugs, both in the registerOneOffTask path:

  1. Callback received uniqueName instead of taskName (🐞 [iOS] registerOneOffTask passes uniqueName as taskName in callback — parameters appear swapped #670). startOneOffTask was called with request.uniqueName as the operation identifier, which is what the native bridge forwards to the Dart callback. It now forwards request.taskName, matching Android behavior. The uniqueName is still used for the beginBackgroundTask debug name and lifecycle.
  2. initialDelay was ignored (🐞registerOneOffTask with initialDelay executes immediately on iOS instead of waiting for the specified delay period. #661). startOneOffTask accepted delaySeconds but never used it, so one-off tasks executed immediately. The operation is now enqueued after the requested delay.

Also:

  • Updated the registerOneOffTask/executeTask doc comments in workmanager_impl.dart to reflect the fixed behavior (and removed the stale “inputData is not supported on iOS” note on periodic tasks, which was fixed by fix(ios): pass inputData to periodic background tasks #648).
  • Added an integration test asserting the callback receives taskName when it differs from uniqueName.

Verification

  • dart analyze clean on workmanager and example
  • dart format --set-exit-if-changed clean
  • flutter test passes in workmanager
  • swiftlint: no new violations (repo baseline is 12 pre-existing warnings)

Note on iOS limits: beginBackgroundTask-based one-off tasks only run while the app is alive; iOS may terminate the app before a long delay elapses. The delay is honored while the app stays alive. This is documented in the updated doc comments.

Fixes #670
Fixes #661

…f tasks

- registerOneOffTask now forwards request.taskName (not uniqueName) to the
  Dart callback, matching Android behavior.
- startOneOffTask now honors delaySeconds before running the task instead
  of executing immediately.
- Update Dart doc comments to reflect the fixed behavior.
- Add integration test asserting the callback receives taskName.

Fixes #670
Fixes #661
@ened
ened merged commit ce8fd12 into main Aug 1, 2026
19 checks passed
ened added a commit that referenced this pull request Aug 2, 2026
The macOS support merge (#689) rewrote WorkmanagerPlugin.swift from an
older base and silently dropped the initialDelay handling added in #687
(commit ce8fd12), so registerOneOffTask with an initialDelay now executes
immediately on iOS again.

Restore the delay logic in startOneOffTask: the operation is enqueued
after delaySeconds via asyncAfter while the beginBackgroundTask budget
stays active, matching the previously merged and released behavior.

Fixes #661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant