You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Migrate to federated plugin architecture for v0.8.0
BREAKING CHANGES:
- Plugin now uses federated architecture with separate platform packages
- Platform-specific implementations moved to dedicated packages
- Main workmanager package depends on platform interface and implementations
New packages:
- workmanager_platform_interface: Shared interface for all implementations
- workmanager_android: Android-specific WorkManager implementation
- workmanager_ios: iOS-specific BGTaskScheduler implementation
Benefits:
- Foundation for macOS support using NSBackgroundActivityScheduler
- Platform experts can contribute to specific implementations
- Better modular development and testing
- Independent platform package releases
This architectural change sets up the plugin for easy platform expansion
while maintaining all existing functionality and incorporating community bugfixes.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
/// print("Replace this print statement with your code that should be executed in the background here");
44
+
/// break;
45
+
/// }
46
+
/// return Future.value(true);
47
+
/// });
48
+
/// }
49
+
///
50
+
/// void main() {
51
+
/// Workmanager().initialize(callbackDispatcher);
52
+
/// }
53
+
/// ```
54
+
///
55
+
/// ## You can schedule a specific iOS task using:
56
+
/// - `Workmanager().registerOneOffTask()`
57
+
/// Please read the documentation on limitations for background processing on iOS.
58
+
///
59
+
///
60
+
/// iOS periodic background fetch task is automatically scheduled if you setup the plugin properly for Background Fetch.
61
+
///
62
+
/// If you are targeting iOS 13+, you can use `Workmanager().registerPeriodicTask()`
63
+
///
64
+
/// Note: On iOS 13+, adding a BGTaskSchedulerPermittedIdentifiers key to the Info.plist
65
+
/// disables the performFetchWithCompletionHandler and setMinimumBackgroundFetchInterval
66
+
/// methods, which means you cannot use both old Background Fetch and new registerPeriodicTask
67
+
/// at the same time, you have to choose one based on your minimum iOS target version.
68
+
/// For details see [Using background tasks to update your app](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app/)
69
+
///
70
+
///
71
+
/// ## You can schedule Android tasks using:
72
+
/// - `Workmanager().registerOneOffTask()` or `Workmanager().registerPeriodicTask()`
/// Initialize the Workmanager with a [callbackDispatcher].
108
+
///
109
+
/// The [callbackDispatcher] is a top level function which will be invoked by Android or iOS whenever a scheduled task is due.
110
+
/// The [isInDebugMode] will post local notifications for every background worker that ran. This is very useful when trying to debug what's happening in the background.
/// A [uniqueName] is required so only one task can be registered.
152
+
/// Calling this method again with the same [uniqueName] will update the current pending task, unless an [ExistingWorkPolicy] is provided.
153
+
/// The [taskName] is the value that will be returned in the [BackgroundTaskHandler], ignored on iOS where you should use [uniqueName].
154
+
/// The [inputData] is the input data for task. Valid value types are: int, bool, double, String and their list
155
+
/// The [initialDelay] is an [Duration] after which the task will run. Ignored on iOS where you should schedule the task in AppDelegate.swift
156
+
/// The [constraints] are the requirements that need to be met before the task runs.
157
+
/// The [backoffPolicy] is the backoff policy to use when retrying work.
158
+
/// The [backoffPolicyDelay] is the delay for the backoff policy.
159
+
/// The [tag] is an optional tag that can be used to identify or cancel the task.
160
+
/// The [existingWorkPolicy] is the policy to use when work with the same [uniqueName] already exists.
161
+
/// The [outOfQuotaPolicy] is the policy to use when the device is out of quota. (Android only)
162
+
Future<void> registerOneOffTask(
163
+
String uniqueName,
164
+
String taskName, {
165
+
Map<String, dynamic>? inputData,
166
+
Duration? initialDelay,
167
+
Constraints? constraints,
168
+
ExistingWorkPolicy? existingWorkPolicy,
169
+
BackoffPolicy? backoffPolicy,
170
+
Duration? backoffPolicyDelay,
171
+
String? tag,
172
+
OutOfQuotaPolicy? outOfQuotaPolicy,
173
+
}) async {
174
+
return _platform.registerOneOffTask(
175
+
uniqueName,
176
+
taskName,
177
+
inputData: inputData,
178
+
initialDelay: initialDelay,
179
+
constraints: constraints,
180
+
existingWorkPolicy: existingWorkPolicy,
181
+
backoffPolicy: backoffPolicy,
182
+
backoffPolicyDelay: backoffPolicyDelay,
183
+
tag: tag,
184
+
outOfQuotaPolicy: outOfQuotaPolicy,
185
+
);
186
+
}
187
+
188
+
/// Schedules a periodic task that will run every provided [frequency].
189
+
///
190
+
/// On iOS it is not guaranteed when or how often it will run, iOS will schedule
191
+
/// it as per user's App usage pattern, iOS might terminate the task or throttle
192
+
/// it's frequency if it takes more than 30 seconds.
193
+
///
194
+
/// A [uniqueName] is required so only one task can be registered.
195
+
/// The [taskName] is the value that will be returned in the [BackgroundTaskHandler], ignored on iOS where you should use [uniqueName].
196
+
/// a [frequency] is not required and will be defaulted to 15 minutes if not provided.
197
+
/// a [frequency] has a minimum of 15 min. Android will automatically change your frequency to 15 min if you have configured a lower frequency.
198
+
/// the [flexInterval] If the nature of the work is time-sensitive, you can configure the PeriodicWorkRequest to run in a flexible period at each interval.
199
+
/// The [inputData] is the input data for task. Valid value types are: int, bool, double, String and their list
200
+
///
201
+
/// Unlike Android, you cannot set [frequency] for iOS here rather you have to set in `AppDelegate.swift` while registering the task.
202
+
/// The [inputData] is the input data for task. Valid value types are: int, bool, double, String and their list. It is not supported on iOS.
203
+
///
204
+
/// For iOS see Apple docs:
205
+
/// [iOS 13+ Using background tasks to update your app](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app/)
/// [iOS 13+ Using background tasks to update your app](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app/)
0 commit comments