Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ import workmanager_apple
}
```

Background engines create their own `FlutterDartProject` by default. If your
app needs them to use the same project as the main engine (for example when a
code push tool resolves the newest downloaded patch each time a project is
created), create one project at launch, pass it to your engine, and call
`WorkmanagerPlugin.setDartProject(_:)` with it before any task runs:

```swift
let project = FlutterDartProject()
WorkmanagerPlugin.setDartProject(project)
```

When the call is omitted, behavior is unchanged.

<Info>
**UIScene lifecycle:** Apple requires UIKit apps to adopt the UIScene lifecycle
from the release following iOS 26. After migration, call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class BackgroundWorker {

var flutterEngine: FlutterEngine? = FlutterEngine(
name: backgroundMode.flutterThreadlabelPrefix,
project: nil,
project: WorkmanagerPlugin.dartProject,
allowHeadlessExecution: true
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public class WorkmanagerPlugin: WorkmanagerPluginBase, FlutterPlugin, Workmanage
/// (fluttercommunity/flutter_workmanager#653).
static var mainBinaryMessenger: FlutterBinaryMessenger?

static var dartProject: FlutterDartProject?

/// Sets the `FlutterDartProject` used by the background engines.
///
/// Without this call each background engine creates its own project. Apps
/// whose project settings change while the app runs (for example code push
/// tools that resolve the newest downloaded patch when a project is
/// created) should create one project at launch and share it with the main
/// engine and with this plugin.
///
/// - Parameter project: The project the host app created at launch
@objc
public static func setDartProject(_ project: FlutterDartProject) {
dartProject = project
}

/// Sets the plugin registrant callback for background task execution.
///
/// This callback is used to register additional plugins when background tasks
Expand Down
Loading