Skip to content

Commit 3bd58bc

Browse files
committed
# Conflicts: # README.md # ios/Classes/SwiftWorkmanagerPlugin.swift
1 parent 6121548 commit 3bd58bc

22 files changed

Lines changed: 246 additions & 246 deletions

File tree

.github/workflows/format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ jobs:
4848
run: |
4949
flutter pub get
5050
flutter pub publish -n
51-
pub global activate tuneup
52-
pub global run tuneup check
51+
flutter pub global activate tuneup
52+
flutter pub global run tuneup check

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
runs-on: macos-latest
3838
steps:
3939
- uses: actions/checkout@v2
40+
- uses: actions/setup-java@v1
41+
with:
42+
java-version: 11
4043
- uses: subosito/flutter-action@v1
4144
with:
4245
channel: 'stable'
@@ -76,6 +79,9 @@ jobs:
7679
target: [default]
7780
steps:
7881
- uses: actions/checkout@v2
82+
- uses: actions/setup-java@v1
83+
with:
84+
java-version: 11
7985
- uses: subosito/flutter-action@v1
8086
with:
8187
channel: 'stable'

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# next
22

3+
* Documentation and example update to fix (#374) WorkManager not working when App is obfuscated or using Flutter 3.1+
4+
5+
# 0.5.0
6+
37
* Android: Remove jetifier from example
8+
* Restore compatibility with Flutter 3.0.0, thank you @Cwiesen and @sunalwaysknows
9+
* Replaces `pedantic` checks with `flutter_lints`
10+
* Ability to specify custom tasks (and custom background work) for iOS was added. Thank you @tuyen-vuduc
411

512
# 0.5.0-dev.8
613

IOS_SETUP.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ This will add the **UIBackgroundModes** key to your project's `Info.plist`:
2222
</array>
2323
```
2424

25-
Additionally, you must configure the background task identifiers. The default identifier is `workmanager.background.task` in the host Apps Info.plist:
25+
You **MUST** amend your `AppDelegate.swift` and `Info.plist` file to register your task ID.
2626

27+
- AppDelegate.swift
28+
``` swift
29+
WorkmanagerPlugin.registerTask(withIdentifier: "task-identifier")
30+
```
31+
32+
- Info.plist
2733
``` xml
2834
<key>BGTaskSchedulerPermittedIdentifiers</key>
29-
<array>
30-
<string>workmanager.background.task</string>
31-
</array>
32-
</plist>
35+
<array>
36+
<string>task-identifier</string>
37+
</array>
38+
</key>
3339
```
3440

3541
And will set the correct *SystemCapabilities* for your target in the `project.pbxproj` file:

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ See sample folder for a complete working example.
2323
Before registering any task, the WorkManager plugin must be initialized.
2424

2525
```dart
26+
@pragma('vm:entry-point') // Mandatory if the App is obfuscated or using Flutter 3.1+
2627
void callbackDispatcher() {
2728
Workmanager().executeTask((task, inputData) {
2829
print("Native called background task: $backgroundTask"); //simpleTask will be emitted here.
@@ -71,7 +72,10 @@ void callbackDispatcher() {
7172
}
7273
```
7374

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.
7579

7680
---
7781

@@ -87,14 +91,14 @@ On Android, the `BackoffPolicy` will configure how `WorkManager` is going to ret
8791

8892
Refer to the example app for a successful, retrying and a failed task.
8993

90-
# Customisation (iOS - BGTaskScheduler only)
94+
# iOS specific setup and note
9195

9296
iOS supports **One off tasks** with a few basic constraints
9397
(Note on iOS this is for long-running Processing tasks run every 1-2 days):
9498

9599
```dart
96100
Workmanager().registerOneOffTask(
97-
"1", // Ignored on iOS
101+
"task-identifier",
98102
simpleTaskKey, // Ignored on iOS
99103
initialDelay: Duration(minutes: 30),
100104
constraints: Constraints(
@@ -130,14 +134,14 @@ Two kinds of background tasks can be registered :
130134
```dart
131135
// One off task registration
132136
Workmanager().registerOneOffTask(
133-
"1",
137+
"oneoff-task-identifier",
134138
"simpleTask"
135139
);
136140
137141
// Periodic task registration
138142
Workmanager().registerPeriodicTask(
139-
"2",
140-
"simplePeriodicTask",
143+
"periodic-task-identifier",
144+
"simplePeriodicTask",
141145
// When no frequency is provided the default 15 minutes is set.
142146
// Minimum frequency is 15 min. Android will automatically change your frequency to 15 min if you have configured a lower frequency.
143147
frequency: Duration(hours: 1),

analysis_options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:flutter_lints/flutter.yaml
22

33
linter:
44
rules:

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ group 'be.tramckrijte.workmanager'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.5.31'
5+
ext.kotlin_version = '1.6.21'
66
repositories {
77
google()
88
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:4.2.2'
12+
classpath 'com.android.tools.build:gradle:7.1.3'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}

android/src/main/kotlin/be/tramckrijte/workmanager/BackgroundWorker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class BackgroundWorker(
151151
}
152152

153153
override fun error(
154-
errorCode: String?,
154+
errorCode: String,
155155
errorMessage: String?,
156156
errorDetails: Any?
157157
) {

example/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.5.31'
2+
ext.kotlin_version = '1.6.21'
33
repositories {
44
google()
55
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.2.2'
9+
classpath 'com.android.tools.build:gradle:7.1.3'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

0 commit comments

Comments
 (0)