Skip to content

Commit 62c3485

Browse files
authored
deprecation notice & changelog (#385)
* deprecation notice & changelog * docs
1 parent 01e93fd commit 62c3485

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Android: Remove jetifier from example
44
* Restore compatibility with Flutter 3.0.0, thank you @Cwiesen and @sunalwaysknows
55
* Replaces `pedantic` checks with `flutter_lints`
6+
* Ability to specify custom tasks (and custom background work) for iOS was added. Thank you @tuyen-vuduc
67

78
# 0.5.0-dev.8
89

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ On Android, the `BackoffPolicy` will configure how `WorkManager` is going to ret
8787

8888
Refer to the example app for a successful, retrying and a failed task.
8989

90-
# iOS speicific setup and note
90+
# iOS specific setup and note
9191

9292
iOS supports **One off tasks** with a few basic constraints:
9393

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import workmanager
2727
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simpleDelayedTask")
2828
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simplePeriodicTask")
2929
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simplePeriodic1HourTask")
30-
30+
3131
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
3232

3333
}

lib/src/workmanager.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'options.dart';
1212
///
1313
/// [taskName] Returns the value you provided when registering the task.
1414
/// iOS will pass [Workmanager.iOSBackgroundTask] (for background-fetch) or
15-
/// [Workmanager.iOSBackgroundProcessingTask] for BGTaskScheduler based tasks.
15+
/// custom task IDs for BGTaskScheduler based tasks.
1616
///
1717
/// The behavior for retries is different on each platform:
1818
/// - Android: return `false` from the this method will reschedule the work
@@ -105,6 +105,7 @@ class Workmanager {
105105
/// });
106106
/// }
107107
/// ```
108+
@Deprecated('Use custom iOS task names. This property will be removed.')
108109
static const String iOSBackgroundProcessingTask =
109110
"workmanager.background.task";
110111

test/workmanager_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import 'package:workmanager/src/workmanager.dart';
77

88
import 'workmanager_test.mocks.dart';
99

10+
const testTaskName = 'ios-background-task-name';
11+
1012
Future<bool> testCallBackDispatcher(task, inputData) {
1113
return Future.value(true);
1214
}
1315

1416
void mySetUpWrapper() {
1517
GetIt.I<Workmanager>().initialize(testCallBackDispatcher);
1618
GetIt.I<Workmanager>().cancelAll();
17-
GetIt.I<Workmanager>()
18-
.cancelByUniqueName(Workmanager.iOSBackgroundProcessingTask);
19+
GetIt.I<Workmanager>().cancelByUniqueName(testTaskName);
1920
}
2021

2122
@GenerateMocks([Workmanager])
@@ -46,8 +47,7 @@ void main() {
4647
mySetUpWrapper();
4748

4849
verify(GetIt.I<Workmanager>().initialize(testCallBackDispatcher));
49-
verify(GetIt.I<Workmanager>()
50-
.cancelByUniqueName(Workmanager.iOSBackgroundProcessingTask));
50+
verify(GetIt.I<Workmanager>().cancelByUniqueName(testTaskName));
5151
});
5252
});
5353
}

0 commit comments

Comments
 (0)