flutter_workmanager icon indicating copy to clipboard operation
flutter_workmanager copied to clipboard

iOS set up error: type 'WorkmanagerPlugin' has no member 'registerTask'

Open jafitz26 opened this issue 3 years ago • 6 comments

  • [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

Describe the error After following the iOS set up guide, I am receiving this error from my AppDelegate when trying to run the app:

error: type 'WorkmanagerPlugin' has no member 'registerTask'

Here is my AppDelegate:

import UIKit
import Flutter
import workmanager

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      InitUnityIntegrationWithOptions(argc: CommandLine.argc, argv: CommandLine.unsafeArgv, launchOptions)
    GeneratedPluginRegistrant.register(with: self)
      UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
      WorkmanagerPlugin.registerTask(withIdentifier: "com.bundle.app.1")
      WorkmanagerPlugin.registerTask(withIdentifier: "com.bundle.app.2")
      if #available(iOS 10.0, *) {
           UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
         }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
```


**Output of `flutter doctor -v`**

jafitz26 avatar May 19 '22 22:05 jafitz26

Found the solution with this thread: https://github.com/fluttercommunity/flutter_workmanager/issues/189

Replace WorkmanagerPlugin.registerTask(withIdentifier: "com.bundle.app.1") WorkmanagerPlugin.registerTask(withIdentifier: "com.bundle.app.2")

with: WorkmanagerPlugin.register(with: self.registrar(forPlugin: "com.bundleId.workmanager.WorkmanagerPlugin")!)

jafitz26 avatar May 20 '22 05:05 jafitz26

@jafitz26 It's not ?

WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!)

I got the following error :

flutter: PlatformException(bgTaskSchedulingFailed(Error Domain=BGTaskSchedulerErrorDomain Code=3 "(null)") error, Scheduling the task using BGTaskScheduler has failed.


This may be due to too many tasks being scheduled but not run.


See the error for details: Error Domain=BGTaskSchedulerErrorDomain Code=3 "(null)"., null, null)

Edit : For people on 0.5.0-dev.8, we can only use "workmanager.background.task" as task identifier for background processing.

ghost avatar May 31 '22 14:05 ghost

For people on 0.5.0-dev.8, we can only use "workmanager.background.task" as task identifier for background processing.

Hi, Where I can find this info?

kitoheedong avatar Sep 23 '22 03:09 kitoheedong

For people on 0.5.0-dev.8, we can only use "workmanager.background.task" as task identifier for background processing.

Hi, Where I can find this info?

In source code and older doc version.

EArminjon avatar Sep 23 '22 07:09 EArminjon

Which documents? Do you have a link?

For people on 0.5.0-dev.8, we can only use "workmanager.background.task" as task identifier for background processing.

Hi, Where I can find this info?

In source code and older doc version.

Which documents? Do you have a link?

umbertopollarini avatar Aug 19 '23 14:08 umbertopollarini

Which documents? Do you have a link?

For people on 0.5.0-dev.8, we can only use "workmanager.background.task" as task identifier for background processing.

Hi, Where I can find this info?

In source code and older doc version.

Which documents? Do you have a link?

Source code of the SDK.

EArminjon avatar Aug 20 '23 07:08 EArminjon