fix(ios): pass taskName to callback and honor initialDelay for one-off tasks - #687
Merged
Merged
Conversation
…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
This was referenced Aug 2, 2026
Closed
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Two related iOS one-off task bugs, both in the
registerOneOffTaskpath:uniqueNameinstead oftaskName(🐞 [iOS]registerOneOffTaskpassesuniqueNameastaskNamein callback — parameters appear swapped #670).startOneOffTaskwas called withrequest.uniqueNameas the operation identifier, which is what the native bridge forwards to the Dart callback. It now forwardsrequest.taskName, matching Android behavior. TheuniqueNameis still used for thebeginBackgroundTaskdebug name and lifecycle.initialDelaywas ignored (🐞registerOneOffTaskwithinitialDelayexecutes immediately on iOS instead of waiting for the specified delay period. #661).startOneOffTaskaccepteddelaySecondsbut never used it, so one-off tasks executed immediately. The operation is now enqueued after the requested delay.Also:
registerOneOffTask/executeTaskdoc comments inworkmanager_impl.dartto 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).taskNamewhen it differs fromuniqueName.Verification
dart analyzeclean onworkmanagerandexampledart format --set-exit-if-changedcleanflutter testpasses inworkmanagerNote 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