flutter_workmanager
flutter_workmanager copied to clipboard
[Doc] IOS callback not called
- [x] I have read the README
- [x] I have done the setup for Android
- [x] I have done the setup for iOS
- [x] I have ran the sample app and it does not work there
Version flutter 2.10.3
Technology | Version |
---|---|
Workmanager version | 0.5.0-dev.8 |
Xcode version | 13.3.1 |
Swift version | |
iOS deployment target | 11 |
Describe the error
Describe error
Optionally provide the least amount of code that shows this behaviour. Ideally in the sample
app.
void callbackDispatcher() {
debugPrint("test");
Workmanager().executeTask((
String task,
Map<String, dynamic>? json,
) async {
debugPrint("test 2");
return true;
}
}
await Workmanager().initialize(
callbackDispatcher,
isInDebugMode: kDebugMode,
);
Workmanager().registerOneOffTask(
"workmanager.background.task",
"workmanager.background.task",
tag: "workmanager.background.task",
)
The callback is never called on iOS, despite the fact that it works on Android... I've done all the iOS setup part with 'workmanager.background.task' as task identifier because i use WorkManager 0.5.0-dev.8
Output of flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.3.1 21E258 darwin-arm, locale fr-FR)
• Flutter version 2.10.3 at /Users/*********/fvm/versions/2.10.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 months ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/*********/Library/Android/Sdk
• Platform android-32, build-tools 32.1.0-rc1
• ANDROID_HOME = /Users/**********/Library/Android/Sdk
• Java binary at: /Users/********/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8609683/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Connected device (2 available)
• iPhone de ******** (mobile) • 037a70ff3ad9e7787722c6c239f94d2aadceb764 • ios • iOS 15.4.1 19E258
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61
https://github.com/fluttercommunity/flutter_workmanager/issues/397
To run background processing : you need to run app on xcode and put a breakpoint after register your task. On xcode breakpoint console, run the following command and then continue your app :
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"workmanager.background.task"]
Need to update doc.
Doc should mention how to stop ios background processing :
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateExpirationForTaskWithIdentifier:@"workmanager.background.task"]
Any way to avoid doing these tricks (breakpoint + command) while developing on IOS ?
I run the following code after breakpoint e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateExpirationForTaskWithIdentifier:@"workmanager.background.task"] but I'm getting this error Error [IRForTarget]: Couldn't resolve the class for an Objective-C static method call
To run background processing : you need to run app on xcode and put a breakpoint after register your task. On xcode breakpoint console, run the following command and then continue your app :
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"workmanager.background.task"]
Are there any ways to debug the dart code after using this trick?
I also want to know if there are any ways to debug dart code after doing this.
I also have this problem. Does the Workmanager Plugin not work for iOS? Did some of the people here solve this problem?
Any updates? Same problem Flutter Channel stable, 3.7.0
Any update on this?
I get the impression the Workmanger plugin does work on iOS, as I can put a breakpoint after registering, and then do the simulate launch. This method needs to be written in the iOS setup doc, because referencing Apple's "Starting and Terminating Tasks During Development" does not help.
The problem is that when calling registerOneOffTask
it does not fire the callback. Which has now newly created issue #450.
yes, this issue still exists. But only while using the simulator. I have tested this with a real device. Despite passing Duration.zero
for initialDelay
and despite the comment in the example "Most likely this will trigger immediately", it took 15 minutes until the task got executed. When triggering a background fetch with Xcode (described in the iOS setup guide) the task executes immediately.
I just run the example, it not work on iOS......
Unhandled Exception: PlatformException(bgTaskSchedulingFailed(Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)") error, Scheduling the task using BGTaskScheduler has failed.
I just run the example, it not work on iOS......
Unhandled Exception: PlatformException(bgTaskSchedulingFailed(Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)") error, Scheduling the task using BGTaskScheduler has failed.
#441