我一直在关注Flutter Workmanager iOS 设置,在页面底部,他们展示了如何将插件与 Workmanager 一起使用来执行后台任务。
我的 AppDelegate.swift 中有这个确切的代码:
class AppDelegate: FlutterAppDelegate {
/// Registers all pubspec-referenced Flutter plugins in the given registry.
static func registerPlugins(with registry: FlutterPluginRegistry) {
GeneratedPluginRegistrant.register(with: registry)
}
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ... Initialization code
AppDelegate.registerPlugins(with: self) // Register the app's plugins in the context of a normal run
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
// The following code will be called upon WorkmanagerPlugin's registration.
// Note …Run Code Online (Sandbox Code Playgroud)