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
I'm trying to run a one-off task using the work manager plugin. Works fine on android, but on IOS I'm running into some issues.
I have set up as per the documentation here https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md. The only part of this I'm unclear on is in my info.plist and app delegate I have to register the task. I have seen on some SO and GitHub threads such as here that I should be including my bundle ID before the task name. Should I be doing this in one, both or neither of these places.
I am running on an physical iPhone XR iOS 16.5.1 and am trying everything in both release and debug mode.
My appdelegate.swift (some values edited, function names edited but keep same format)
@pragma('vm:entry-point')
void callbackDispatcher() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
var messaging = FirebaseMessaging.instance;
var analytics = FirebaseAnalytics.instance;
Workmanager().executeTask((task, inputData) async {
if (task == "taskName1") {
//Do some things and return result
}
}
}
For the most part I get the error
flutter: PlatformException(bgTaskSchedulingFailed(Error Domain=BGTaskSchedulerErrorDomain Code=3 "(null)") error, Scheduling the task using BGTaskScheduler has failed.
This implies that my set up is wrong, but I don't see where I have gone wrong.
I tried a solution where I changed my pubspec.yaml from including work manager: ^0.5.2 to this
This removed the error however the tasks were not running, even after leaving the application running on a physical device overnight. I did get this error in that case
[BackgroundTask] Background Task 27 ("task name"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
As UIApplication.endBackgroundTask is swift (I believe) I have absolutely no clue how to call that through flutter.
Any help would be greatly appreciated. I can see plenty of threads with people having issues running work manager on IOS (and just general background tasks, which I understand IOS doesn't make easy) but I'm seeing very few solutions, and none so far that work for me.
The text was updated successfully, but these errors were encountered:
I have the same problem, I'm trying to find a solution/workaround since 3 months but nothing works for me.
I need to use intialize a db in background but the background process can't find path_provider lib.
If anyone can share any suggestions or solution to this problem It would be appreciated thank you.
Hi, I was looking at refreshing tokens in the background using work manager. On IOS, is it possible to trigger one of task with same ids multiple times? If I have to permit the ids upfront, then I cant register one off task few mins before the token expiry to refresh it. Any suggestions on how to do this?
Also, is it possible to register the one of task (in swift code) with name instead of id?
I'm trying to run a one-off task using the work manager plugin. Works fine on android, but on IOS I'm running into some issues.
I have set up as per the documentation here https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md. The only part of this I'm unclear on is in my info.plist and app delegate I have to register the task. I have seen on some SO and GitHub threads such as here that I should be including my bundle ID before the task name. Should I be doing this in one, both or neither of these places.
I am running on an physical iPhone XR iOS 16.5.1 and am trying everything in both release and debug mode.
My appdelegate.swift (some values edited, function names edited but keep same format)
project.pbxproj
info.plist
Dart code for tasks is laid out like this for all tasks. They all are one-off tasks and have either a delay of zero, 5 seconds or up to one hour.
Dart code for receiving tasks in main.dart
For the most part I get the error
flutter: PlatformException(bgTaskSchedulingFailed(Error Domain=BGTaskSchedulerErrorDomain Code=3 "(null)") error, Scheduling the task using BGTaskScheduler has failed.
This implies that my set up is wrong, but I don't see where I have gone wrong.
I tried a solution where I changed my pubspec.yaml from including work manager: ^0.5.2 to this
This removed the error however the tasks were not running, even after leaving the application running on a physical device overnight. I did get this error in that case
[BackgroundTask] Background Task 27 ("task name"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
As UIApplication.endBackgroundTask is swift (I believe) I have absolutely no clue how to call that through flutter.
Any help would be greatly appreciated. I can see plenty of threads with people having issues running work manager on IOS (and just general background tasks, which I understand IOS doesn't make easy) but I'm seeing very few solutions, and none so far that work for me.
The text was updated successfully, but these errors were encountered: