i am making an attempt to make use of workermanger with flutter about background service on ios.
So that is my plist
Now that is my AppDelegate on xcode:
import UIKit
import Flutter
import workmanager
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func userNotificationCenter(_ middle: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert) // exhibits banner even when app is in foreground
}
override func software(_ software: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
WorkmanagerPlugin.registerTask(withIdentifier: "simpleTask")
UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
GeneratedPluginRegistrant.register(with: self)
return tremendous.software(software, didFinishLaunchingWithOptions: launchOptions)
}
}
and now that is my Flutter code
import 'package deal:workmanager/workmanager.dart';
@pragma('vm:entry-point')
void callbackDispatcher() {
Workmanager().executeTask((process, inputData) {
change (process) {
case Workmanager.iOSBackgroundTask:
print("The iOS background fetch was triggered");
break;
}
bool success = true;
return Future.worth(success);
});
}
void predominant() {
WidgetsFlutterBinding.ensureInitialized();
Workmanager().initialize(
callbackDispatcher, // The highest degree perform, aka callbackDispatcher
isInDebugMode: true // If enabled it should put up a notification at any time when the duty is operating. Helpful for debugging duties
);
Workmanager().registerOneOffTask("simpleTask", "simpleTask");
// Workmanager().registerPeriodicTask("simpleTask", "simpleTask");
runApp(const MyApp());
}
The error i obtain is that this:
Couldn't schedule app refresh: Error Area=BGTaskSchedulerErrorDomain Code=3 "(null)"
are you able to recommend me the place i am misplaced? Perhaps in regards to the documentation, i can not perceive i ask assist to you.