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
Copy file name to clipboardExpand all lines: README.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ See sample folder for a complete working example.
23
23
Before registering any task, the WorkManager plugin must be initialized.
24
24
25
25
```dart
26
+
@pragma('vm:entry-point') // Mandatory if the App is obfuscated or using Flutter 3.1+
26
27
void callbackDispatcher() {
27
28
Workmanager().executeTask((task, inputData) {
28
29
print("Native called background task: $backgroundTask"); //simpleTask will be emitted here.
@@ -71,7 +72,10 @@ void callbackDispatcher() {
71
72
}
72
73
```
73
74
74
-
Android tasks are identified using their `taskName`, whereas two default constants are provided for iOS background operations, depending on whether background fetch or BGTaskScheduler is used: `Workmanager.iOSBackgroundTask` & `Workmanager.iOSBackgroundProcessingTask`.
75
+
Android tasks are identified using their `taskName`.
76
+
iOS tasks are identitied using their `taskIdentifier`.
77
+
78
+
However, there is an exception for iOS background fetch: `Workmanager.iOSBackgroundTask`, a constant for iOS background fetch task.
75
79
76
80
---
77
81
@@ -87,14 +91,14 @@ On Android, the `BackoffPolicy` will configure how `WorkManager` is going to ret
87
91
88
92
Refer to the example app for a successful, retrying and a failed task.
89
93
90
-
# Customisation (iOS - BGTaskScheduler only)
94
+
# iOS specific setup and note
91
95
92
96
iOS supports **One off tasks** with a few basic constraints
93
97
(Note on iOS this is for long-running Processing tasks run every 1-2 days):
94
98
95
99
```dart
96
100
Workmanager().registerOneOffTask(
97
-
"1", // Ignored on iOS
101
+
"task-identifier",
98
102
simpleTaskKey, // Ignored on iOS
99
103
initialDelay: Duration(minutes: 30),
100
104
constraints: Constraints(
@@ -130,14 +134,14 @@ Two kinds of background tasks can be registered :
130
134
```dart
131
135
// One off task registration
132
136
Workmanager().registerOneOffTask(
133
-
"1",
137
+
"oneoff-task-identifier",
134
138
"simpleTask"
135
139
);
136
140
137
141
// Periodic task registration
138
142
Workmanager().registerPeriodicTask(
139
-
"2",
140
-
"simplePeriodicTask",
143
+
"periodic-task-identifier",
144
+
"simplePeriodicTask",
141
145
// When no frequency is provided the default 15 minutes is set.
142
146
// Minimum frequency is 15 min. Android will automatically change your frequency to 15 min if you have configured a lower frequency.
0 commit comments