我正在尝试使用 Work manager 包进行颤振,但似乎有些问题......这是我尝试过的:
main.dart
...
...
void callbackDispatcher() {
// this method will be called every hour
Workmanager.executeTask((task, inputdata) async {
switch (task) {
case "track_location":
print("this method was called from native!");
break;
case Workmanager.iOSBackgroundTask:
print("iOS background fetch delegate ran");
break;
}
//Return true when the task executed successfully or not
return Future.value(true);
});
}
...
...
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Workmanager.initialize(callbackDispatcher);
await Firebase.initializeApp();
...
...
当我尝试运行应用程序时出现此错误:
70): Cannot access 'workmanagerCallHandler': it is private in 'WorkmanagerPlugin'